You may also use : {{if request.is_local:}} {{=response.toolbar()}} {{pass}}
In your view which if you click on the button will let you know all the db.request perform by your web page request... Richard On Tue, Jul 14, 2015 at 9:44 AM, Richard Vézina <ml.richard.vez...@gmail.com > wrote: > Mirek, > > db.region(r.region_id).name = db(db.region.id == id).select(db.region.name > ) > > So this is 1 request... I wasn't know r.region_id.name, so if this is > perform under the houd by web2py there is no supplementary request except > if this request is lazy, mean that if performs only when you call it > explicitly and the code get interpreted... > > Richard > > On Mon, Jul 13, 2015 at 6:10 AM, Mirek Zvolský <zvol...@seznam.cz> wrote: > >> Thank you, Massimo. >> Great ! This works: format = lambda r: '%s - %s' % (r.name, >> r.region_id.name <http://r.region.name/>) >> If region_id is None it should be handled again: format = lambda r: '%s - >> %s' % (r.name, r.region_id.name <http://r.region.name/> if r.region_id >> else '?') >> >> Lot of questions in addition: >> - is this documented in book? >> - is r.region_id.name <http://r.region.name/> internally the same like >> db.region(r.region_id).name ? >> - how many sql commands are generated in grid or in IS_IN_DB, and if >> many, is there a way to avoid this? >> >> >> >> Dne neděle 12. července 2015 23:22:39 UTC+2 Massimo Di Pierro napsal(a): >> >>> 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 web2py+unsubscr...@googlegroups.com. >> For more options, visit https://groups.google.com/d/optout. >> > > -- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.