seanb schrieb:
> Hi all,
> 
> I'm having a problem saving data to my sqlite database from a form.
> I've checked the data being returned by the form and it all comes out
> fine. However if I save the data to the database, the items in my
> database of type ForeignKey() come out as none (when viewed via
> catwalk).
> 
> For example:
> 
> class Person (SQLObject):
>       personID        = UnicodeCol(alternateID=True)
>       firstName       = UnicodeCol()
>       surname = UnicodeCol()
>       email           = UnicodeCol()
>       phone   = UnicodeCol()
>       addressID       = ForeignKey('Address')
>       companyID       = ForeignKey('Company')
>       relationship = ForeignKey('Relationship')
> 
>       @expose(template="rec.templates.add")
>       def save_person(self, firstName, surname, email, phone, companyID,
> addressID, relationship, personID):
>               sp=Person(firstName=firstName, surname=surname, email=email,
> phone=phone, companyID=Company.selectBy(id=companyID),
> addressID=Address.selectBy(id=addressID),
> relationship=Relationship.selectBy(id=relationship),
> personID=personID)
>               raise redirect("/index")
> 
> I've tried passing them as objects or as numbers (the ID of the
> foreign entity) with no success. Is there a separate method I need to
> use to have these saved?


Certainly not. But you are in naming-trouble here. Instead of calling 
things "nameID", just call them "name". That's because SO will append an 
ID-suffix itself.

Then, either do

address = Address.get(addressID)
SomeObject(address=address)

or

SomeObject(addressID=addressID)

Diez

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