"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes:
> Hi folks,
>
> I'm having a coding dilemma with regards to multiple sql model objects
> that have a dependency.
>
> For example class1 has a dependency on class2. Other examples include
> single or multiple joins.
> ---------
> class class1(SQLObject):
> param1 = ForeignKey('class2')
>
> class class2(SQLObject):
> param1 = IntCol(length=255)
> ---------
>
> c1 = class1(param1=None)
>
> In a case such as this, how do I initialize a class1 object? Do i need
> to initialize a class2 object first and then pass it into the class1
> initializer? How would this work with a multiple join?
You're creating a ForeignKey constraint that isn't mandatory. If you want to
insert some value for param1 in class1 you have to have it already created in
class2.
You can always do as the SQL Object docs show:
c2 = class2(param1=100)
c1 = class1(param1=c2)
You can also do:
c1 = class1(param1ID=c2.id)
Take some time to read SQL Object's documentation that it will be worth to
you.
--
Jorge Godoy <[EMAIL PROTECTED]>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---