a, sorry, my fault, didn't notice that the id field is none. thanks for
show me my own mistake. is there a way to arrange the result for that?
e.g. expected result :
root
- child 1
- child 2
thanks and best regards,
stifan
p.s.
i've change the code into :
*models/db_wizard.py*
# coding: utf8
fr
I think in
for node in treeproxy.ancestors(db.mytree(id)).select():
print node.name
or
for node in treeproxy.descendants(db.mytree(id)).select():
print node.name
db.mytree(id) is None.
On Sunday, 10 November 2013 17:41:11 UTC-6, 黄祥 wrote:
>
> i found on internet something like :
> models/
i found on internet something like :
models/db.py
from gluon.dal import Table
class TreeProxy(object):
skeleton = Table(None, 'tree',
Field('ileft', 'integer'),
Field('iright', 'integer'))
def __init__(self, table):
self.table = table
def ancestors(self, node):
db = self.table._db
return db(se
Perhaps you can try other methods to model parent-child relationship?
These are related to Closure Table but also talk about other methods:
http://stackoverflow.com/questions/192220/what-is-the-most-efficient-elegant-way-to-parse-a-flat-table-into-a-tree
http://dirtsimple.org/2010/11/simplest-wa
hi,
i've tested it using coalesce but the result is not my expected (only print
sub category).
*coalesce in controller*
categories=db((db.category.is_active==True) &
(db.category.parent.coalesce(db.category.category))).select(
5 matches
Mail list logo