On Tue, Oct 5, 2010 at 2:20 PM, pk1024 <[email protected]> wrote:

> I have two classes in my model. One is the definition for ledger
> accounts the other for account posting groups.
>
> So for example I have 100 accounts defined in the "Accounts" class.
>
> Now in my PostingCode class I have a couple fields that are trying to
> all relate to different accounts in the account class.
>
>    accounts_receivable_id =
> Column(Integer,ForeignKey('gl_account.account_id'))
>    accounts_receivable = relation(Account)
>    deposits_id = Column(Integer,ForeignKey('gl_account.account_id'))
>    deposits = relation(Account)
>
> I understand why this doesn't work but I don't understand how to do
> what I am trying to do or even what I would google for.
>
> TIA,
> Paul
>
> --
> You received this message because you are subscribed to the Google Groups
> "TurboGears" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<turbogears%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/turbogears?hl=en.
>
>

You can tell SQLAlchemy more information about the join, most times
'primaryjoin' is enough.
More info:
http://www.sqlalchemy.org/docs/reference/orm/mapping.html?highlight=relation#sqlalchemy.orm.relation

Example:
accounts_receivable_id = Column(Integer,ForeignKey('gl_account.account_id'))
accounts_receivable = relation(Account,
primaryjoin=accounts_receivable_id==Account.account_id)
deposits_id = Column(Integer,ForeignKey('gl_account.account_id'))
deposits = relation(Account, primaryjoin=deposits_id==Account.account_id)


Hope that helps,

-- 
Vince Spicer
Lead Developer - MCE Computing

-- 
Sent from Ubuntu

-- 
You received this message because you are subscribed to the Google Groups 
"TurboGears" 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/turbogears?hl=en.

Reply via email to