On Mar 5, 2011, at 10:43 AM, farcat wrote:

> Hi,
> 
> I am trying to implement polymorphism and multiple inheritance by:
> 
> - adding a column to the parent class/table indicating the table from
> which the (polymorphic) class attribute object can be queried
> - adding the attribute name and the parent id to the child table/class
> to be able to find the attribute object in this table
> 
> Now i want to use a descriptor and/or override __getattr__/__setattr__/
> __getattribute__ to insert or get the correct (polymorphic) object
> from the correct table.
> 
> What I was wondering was e.g. whether using a descriptor will inhibit
> SA from functioning correctly. Any tips to implement what i am trying
> to do would be very welcome.


SQLAlchemy uses descriptors for all the mapped attributes and has several 
avenues to augmenting them with your own descriptors.  __getattribute__ and 
__setattr__ work as expected, as does __getattr__ although that only applies to 
names that otherwise don't exist on the object.

We encourage an extremely simple approach to descriptor access which is to name 
the columns in one way, and the descriptor in another.    The "synonym" 
construct does this as does the newer "hybrid attribute" approach. Set and 
delete events can also be intercepted using the events module (new in 0.7 - in 
0.6 use AttributeExtension).



> 
> Cheers, Lars
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To post to this group, send email to sqlalchemy@googlegroups.com.
> To unsubscribe from this group, send email to 
> sqlalchemy+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/sqlalchemy?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to