On Nov 11, 2008, at 4:52 PM, MikeCo wrote:

>
> Thanks for the pointer about remote_side.
>
> In my application, the table definitions are not visible at runtime,
> and the class definitions are autoloaded from the engine. So, I can't
> say remote_side=table.c.id because table is not available. I do have
> this solution that works well:
>
>
>    class People(Base):
>        __tablename__ = 'people'
>        __table_args__ = {'autoload':True}
>
>    People.children = relation(People, cascade="all",
>                backref=backref("parent", remote_side=[People.id]))
>
> but I am wondering if I can move the definition of children into the
> class somehow. Using this form:
>
>
>    class People(Base):
>        __tablename__ = 'people'
>        __table_args__ = {'autoload':True}
>        children = relation(People, cascade="all",
>                backref=backref("parent", remote_side=[People.id]))

class People(Base):
        .... arguments ...
        children = relation(People, backref=backref("parent",  
remote_side="People.id"))

or my preference:

class People(Base):
     __table__ = people_table = Table('people', Base.metadata,  
autoload=True)
     ... arguments ...
     children = relation(People, backref=backref("parent",  
remote_side=people_table.c.id))




--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to