On 5/4/06, venk <[EMAIL PROTECTED]> wrote:

hi,
  I am using TG o.9a5. Can some one give me a simple example of how to
write a one to many relationship for this version? because the
documentation on the sql object's site seems to be broken. by looking
at the User and Group objects used by the identity framework, i too
tought of adding a joinColumn parameter to the MultipleJoin in the form
of joinColumn = 'twuser_id' where the class is TWuser. Yet, no respite.

I gather that the policy for the default id has changed, but no info
seems to be there on how to deal with it.

Can someone help me out?

this is the class definitions i have

class Wuser(SQLObject):
        uname = StringCol(length=30,alternateID = True)
        accounts = MultipleJoin("Waccount",joinColumn='wuser_id')

I'm not sure what you are trying to accomplish the docs about joinColumn say:
http://www.sqlobject.org/SQLObject.html#multiplejoin-one-to-many

that the joinColumn is the column in the other table that you want in this table to refer to.

Now the default for that is the int PK that SQLObject creates so, the sql "magic" here will let you go on with

class Wuser(SQLObject):
        uname = StringCol(length=30,alternateID = True)
        accounts = MultipleJoin("Waccount")

class Waccount(SQLObject):
        mailid = StringCol()
        epasswd = StringCol()
        mailtype = StringCol()
        getmail = StringCol()
        sendmail = StringCol()
        user = ForeignKey('Wuser')

And SQLObject will know how to relate both tables. What I'm not sure is why you need a multiplejoin and a foreignkey.
 



--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to