From: Richard C. <rc...@rm...> - 2008-12-09 17:11:44
|
Hmm, it seems I don't have a problem after all. I have just changed my code to this again and it works. I was sure I'd already tried this approach and got an error. Can I insert this relationship the other way round at all? How could I specify that rBirds is a child of rPets instead of specifying that rPets is the parent of rBirds? I tried: rPets.addChildren(rBirds) But addChildren apparently isn't an attribute. Thanks. Oleg Broytmann wrote: > On Tue, Dec 09, 2008 at 03:30:58PM +0000, Richard Cooke wrote: > >> rBirds = prodcats.new(name="birds", longname="Birds") >> rBirds.parent = rPets >> > > It is possible if the default for the column is None. What problems do > you have? > > Oleg. > |
From: Oleg B. <ph...@ph...> - 2008-12-09 17:30:44
|
On Tue, Dec 09, 2008 at 05:11:38PM +0000, Richard Cooke wrote: > Can I insert this relationship the other way round at all? How could I > specify that rBirds is a child of rPets instead of specifying that rPets > is the parent of rBirds? I tried: > > rPets.addChildren(rBirds) > > But addChildren apparently isn't an attribute. add*() and remove*() functions are added for RelatedJoins only. ForeignKey/MultipleJoin just don't need them (but you can implement them yourself, of course). class rPets(SQLObject): def addChildren(self, rBirds): rBirds.parent = self (just for example) Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Richard C. <rc...@rm...> - 2008-12-10 10:47:51
|
Thanks for your help and clarification. Implementing my own method if I need this sounds good enough for me. Oleg Broytmann wrote: > On Tue, Dec 09, 2008 at 05:11:38PM +0000, Richard Cooke wrote: > >> Can I insert this relationship the other way round at all? How could I >> specify that rBirds is a child of rPets instead of specifying that rPets >> is the parent of rBirds? I tried: >> >> rPets.addChildren(rBirds) >> >> But addChildren apparently isn't an attribute. >> > > add*() and remove*() functions are added for RelatedJoins only. > ForeignKey/MultipleJoin just don't need them (but you can implement them > yourself, of course). > > class rPets(SQLObject): > def addChildren(self, rBirds): > rBirds.parent = self > > (just for example) > > Oleg. > |