Hi all,

Can I propose the following in order to being able to subclass DAL classes?.

We can currently subclass DAL in our own models and use the new class at DAL 
creation time (db = MyDAL(...)), but the problem is that all other classes 
are internally and directly instantiated in DAL.py.

So let's just start with Table for now.

In DAL.__init__, insert the following as the first line:

   self.cls = dict(table=Table)

This 'cls' dict will eventually hold all classes (default or 
overridden/custom) to instantiate within DAL.py, all accessible via the DAL 
instance, and starting with only table for now: db.cls['table'].

Then in DAL.define_table, replace the direct "Table" reference with:

   self.cls['table']

So far all other direct references to Table in DAL.py are for 
"isinstance(...,Table)", which will evaluate to True for the Table 
subclasses anyways.

This way we can now modify db.cls dict (for 'table') and have DAL.py 
instantiate that class in define_table.

So in our models, immediately after creating a new DAL instance (or its 
custom subclass), we can do the following:

   db.cls['table'] = MyTable

Ideally all other DAL classes (Set, Rows, Row, Reference, etc.) will 
eventually follow this method, using the db.cls dict.

Another approach is to have direct instance vars in DAL (e.g. cls_table), 
instead of going through a 'cls' dict, but that would be up to Massimo.

What do you think?, can this go into trunk?.

Thanks,

   Carlos

Reply via email to