[web2py] Re: Not really a web2py issue, but need help

2010-11-29 Thread JmiXIII
Works fine , thanks I saw it was a recurrent question, maybe you should add this in the book On 29 nov, 18:51, mdipierro wrote: > my bad > > def index(): >     rows = dict((r.id,r) for r in db(db.article).select()) >     for id,row in rows.items(): row.children=[] >     for id,row in rows.ite

[web2py] Re: Not really a web2py issue, but need help

2010-11-29 Thread mdipierro
my bad def index(): rows = dict((r.id,r) for r in db(db.article).select()) for id,row in rows.items(): row.children=[] for id,row in rows.items(): if row.f_parent==1: root=row else: rows[row.f_parent].children.append(row) def tree(row): return DIV(H1(row.tit

[web2py] Re: Not really a web2py issue, but need help

2010-11-29 Thread JmiXIII
Hello, here is what I did: db.define_table('article', Field('f_parent','reference article'), Field('title')) ## def index(): rows = dict((r.id,r) for r in db(db.article).select()) for id,row in rows.items(): row.children=[] for id,row in rows.items(): if row.f_pare

[web2py] Re: Not really a web2py issue, but need help

2010-11-29 Thread JmiXIII
That's it I'll try it thanks a lot! On 29 nov, 00:48, mdipierro wrote: > I assume you are trying to build a hierarchial tree of articles and > you want them all from the parent. > > I would do this something like this: > > db.define_table('article',Field('f_parent','reference > article'),Field('

[web2py] Re: Not really a web2py issue, but need help

2010-11-28 Thread mdipierro
I assume you are trying to build a hierarchial tree of articles and you want them all from the parent. I would do this something like this: db.define_table('article',Field('f_parent','reference article'),Field('title')) def index(): rows = dict((r.id,r) for r in db(db.article).select())