[SQLObject] a third way of accessing attributes
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Bud P. B. <bu...@si...> - 2003-05-15 13:58:34
|
Some time ago, Nick and Ian (and others?) discussed about two ways of exposing SQL data through object attributes: * metaclasses (current SQLObject) that set properties * __getattr__ and __setattr__ There seems to be a third way: * Adding methods and properties (attributes) to a class at runtime (sans metaclasses). The advantage I see (yet to be verified) is that this approach allows a very weak coupling of application objects with the backend implementation: There doesn't even seem to be the need to inherit from some "storable" class or similar (SQLObject). Instead, when the Backend is initialized, it simply loops through all ObjMaps in the Mapping and adds attributes and methods accordingly. I kind of like this... For who is interested in more details, I attach a little test that demonstrates this. --bud /----------------------------------------------------------------- | Bud P. Bruegger, Ph.D. | Sistema (www.sistema.it) | Via U. Bassi, 54 | 58100 Grosseto, Italy | +39-0564-411682 (voice and fax) \----------------------------------------------------------------- |