[sqlalchemy] Adapting the polymorphic association example for generic reuse

2011-10-02 Thread Ahmed
I am looking at http://www.sqlalchemy.org/trac/browser/examples/generic_associations/discriminator_on_association.py and trying to adapt the example to one that is generic and can be reused. So I attempted to abstract all the classes. However there seems to be an error in the __new__ function of

Re: [sqlalchemy] Adapting the polymorphic association example for generic reuse

2011-10-02 Thread Michael Bayer
line 21 creates an AssociationBase passing two arguments to the constructor, but AssociationBase has no __init__ and accepts no arguments. I'd strongly recommend using pdb to track down issues like these. On Oct 2, 2011, at 5:26 AM, Ahmed wrote: I am looking at

[sqlalchemy] Impedance mismatch: too much queries?

2011-10-02 Thread Vlad K.
I have an impedance mismatch problem, namely a model in X categories, each having its own set of fields and all having a set of common fields. I solved that with: 1. master table, contains the sequenced pkey and common fields, as well as category discriminator 2. individual category tables

Re: [sqlalchemy] Impedance mismatch: too much queries?

2011-10-02 Thread Vlad K.
Ah, a solution just came to me. If I had 10 categories and denormalized the user_id into them, I can reverse the queries and do only 10 selects, filtered by user_id and joined with the master table on pkey. I'd end up with equal number of rows selected, but only 10 queries issued. The