--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
very nice ....what about the display of the tree in the view ? maybe as a column in a table.
roots = db(db.taxonomy_column).select().as_trees(parent_name="taxonomy_column_parent_fk")
{{row,n=0}}
{{for c in roots:}} {{=' '*n+row.body+'\n'+''.join(show(c,n+1))}}{{pass}}{{=show(roots[0])}}can someone show me syntax for use outside of the "return" statement?In other words, I want to run and display data within a larger function than the example, that already has vars and data I need, and displays other data that needs to appear.My model is self-referencing table with link to parent named: "taxonomy_column_parent_fkIn controllerroots = db(db.taxonomy_column).select().as_trees(parent_name="taxonomy_column_parent_fk")In view
{{for c in roots:}}{{=' '*n+row.body+'\n'+''.join(show(c,n+1))}}{{pass}}Error
<type 'exceptions.NameError'> name 'n' is not defined
thanksAlex Glaros
def show(row,n=0): return ' '*n+row.body+'\n'+''.join(show(c,n+1) for c in row.children)def view_all_objects_in_a_taxonomy(): roots = db(db.taxonomy_column).select().as_trees(parent_name="taxonomy_column_parent_fk") return locals(){{=show(roots[0])}
what would the syntax be Dave? I don't know how to move a def into another def..
This is the default/show1.html template
<top dog - record #1 points to nothing> <2nd dog - record #2 points to 1> <grandchild - record #4 but points to #2 > < record #6, points to 2> < 3nd dog down - record #3 directly points to record# 1> <record # 5, points to #1 top dog>
def show1(): def show(row,n=0): return ' '*n+row.body+'\n'+''.join(show(c,n+1) for c in row.children) roots = db(db.post).select().as_trees() return locals()db.define_table('post', Field('parent_id','reference post'), Field('body')){{extend 'layout.html'}}<h1>This is the default/show1.html template</h1>{{=show(roots[0])}}