On Dec 29, 2011, at 12:20 AM, Ahmed wrote:

>> Without it
>> I would expect the library to dynamically define the User class based on a
>> Base and Session that I supply to it, it would then return me the new User
>> class using that Base.metadata, and I could track that User class within my
>> app.
> 
> Before I heard about sqlahelper, I was starting to code using this
> approach.
> However, the way sqlalchemy functions now, makes it impossible to go
> further with this approach if you will be using relationships. (Mixins
> were a great addition to sqlalchemy 0.7 which gives us more
> flexibility to using sqlalchemy as a third party lib. However, there
> are still missing bits.)
> 
> I wouldn't have resorted to sqlahelper if not for two things (might be
> actually one):
> 
> groups = relationship("Group", secondary=user_groups_table)
> 
> the secondary argument only accepts passing a Table object. if it
> accepts a string (a table name to look up, for example, that is
> evaluated at mapping time) I wouldn't have resorted to
> passing my base around. The obstacle is that to build a table you have
> to have your base at hand.

It's documented that you can pass a lambda:

relationship("Group", secondary=lambda: 
Base.metadata.tables['user_groups_table'])

the string is accepted there as well, just not documented (this is fixed in 
r58937c3f4abe and is building now):

relationship("Group", secondary="user_groups_table")

So with that a given, do we still have a strong need for sqlahelper ?


-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to