Could you explain to us in English what you are trying to model? I am sure there is a simpler solution using link tables.
On 3 Lug, 12:14, Rick Hultgren <sababa.sab...@gmail.com> wrote: > Thanks for the link. My actual problem is more complicated than the > example I gave. I realize that I need to link a field to a table that > isn't initiated yet (item2): > > objects = ['substance', 'process', 'condition', 'locus'] > linksubobjects = ['locus', 'before', 'after'] > unlinksubobjects = ['name', 'main_name'] > for object in objects: > for item1 in linksubobjects+unlinksubobjects: > for item2 in objects: > fields=[Field(item1, 'reference item2')] > db.define_table(object,*fields) > > I suppose the solution would be to initiate the table names and then > add the fields either in db.py, or in the controller file. But I have > no idea how to do this. > > On 7/3/10, Yarko Tymciurak <resultsinsoftw...@gmail.com> wrote: > > > The online book has a fairly useful search; > > > For your question, see: > >http://web2py.com/book/default/section/6/13 > > > Regards, > > - Yarko > > > On Jul 3, 8:45 am, Rick <sababa.sab...@gmail.com> wrote: > >> Hi, > > >> I would like to link a table to its own model like this: > > >> db.define_table('person', > >> Field('name'), > >> Field('child', db.person)) > > >> I understand that I should first initiate the table and then link it > >> to itself. But how to do that? > > >> Thanks in advance for help!