Thank this should have worked:
db.define_table('company', ... , format = lambda r: '%s - %s' % (r.name,
r.region_id.name <http://r.region.name/>))
r is a company and it does not have a .region, it has a .region_id which is
a reference.
On Sunday, 12 July 2015 15:18:44 UTC-5, Mirek Zvolský wrote:
>
> So, I wasn't succesfull with
> db.define_table('company', ... , format = lambda r: '%s - %s' % (r.name,
> r.region.name))
>
> I was successfull with
> db.define_table('company', ..., format = lambda r: '%s - %s' % (r.name,
> db.region(r.region_id).name)
> or db.define_table('company', ..., format = lambda r: '%s - %s' % (r.name,
> db.region[r.region_id].name)
> and that is enough if I use implicit IS_IN_DB validator for region_id:
> then each company must have region defined.
>
> For more robust solution (and always if companies without region can exist
> in database, like if there is requires=IS_EMPTY_OR(IS_IN_DB(..))), we must
> handle the undefined region_id.
> So we need something like:
> db.define_table('company', ..., format = lambda r: '%s - %s' % (r.name,
> db.region(r.region_id).name if r.region_id else '?'))
> or db.define_table('company', ..., format = lambda r: '%s%s' % (r.name, '
> - ' + db.region(r.region_id).name if r.region_id else ''))
>
> ------
> Thats good for me at this point.
> But I don't know, how many SQL commands are internally generated lets say
> in SQLFORM.grid or in IS_IN_DB()-combobox.
> I have to find in web2py book how to log all sql select commands. Or if
> somebody can give me a hint here..?
> I know about -F 'profiler.log' but I don't know how to read .prof
> files. And maybe there is something much easier?
>
>
--
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/d/optout.