Hi
I am looking for a way to expand all referenced fields and have read about
the as_trees() method for selecting rows. I do not quite understand the
parent field requirement, but say we have the following
tables/relationships, was looking for a nested dict output which could be
JSONified as follows:
db.define_table('customers',
Field('name'),
Field('email'),
Field('address')
)
db.define_table('products',
Field('name'),
Field('description')
)
db.define_table('orders',
Field('customer', db.customers),
Field('order_date', 'date'),
Field('discount', 'double')
)
db.define_table('orders_line',
Field('order', db.orders),
Field('product', db.products),
Field('price', 'double'),
Field('qty', 'double')
)
db(db.orders_line.order==123).select().as_trees()
would give
[{'order':{'id':123, 'customer':{'id':1, 'name':'Bob', 'email':
'[email protected]', 'address':None}, 'order_date':'2014/01/29', 'discount': 0},
'product':{'id':1, 'name':'desk', 'description':'Wood finish, 4-legs'},
'price':100.0, 'qty': 1.0}]
I get the following error: *** AttributeError: AttributeError("'Row' object
has no attribute 'id'",)
Any suggestions?
--
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.