The problem is that table._format is used to build field.represent only for
references only when format is a string. In your case it is a function
which performs a nested query. That is very expensive. Web2py wants you to
be explicit before using it that to build a dropdown. It works (in the
first case) but it considerably slows down your code.
On Wednesday, 27 March 2013 00:43:53 UTC-5, 黄祥 wrote:
>
> hi,
>
> i've already define format in table but it seems return the id instead of
> the format i've define, when i define represent on the field of the other
> field it can work. is it normal?
>
> *e.g. work*
> db.define_table('booking',
> Field('scheduled_start', 'datetime'),
> Field('due_date', 'datetime'),
> Field('court', 'reference court'),
> Field('customer', 'reference customer'),
> Field('description', 'text'),
> format=lambda r: '%s %s-%s-%s' % (r.customer.first_name,
> r.customer.last_name,
> r.court.branch.address,
> r.court.court_no))
>
> db.define_table('check_in',
> Field('is_booking', 'boolean'),
> Field('booking', 'reference booking'*, represent=lambda id, r: '%s
> %s-%s-%s' % (r.customer.first_name, r.customer.last_name,
> r.court.branch.address, r.court.court_no)*),
> Field('court', 'reference court'),
> Field('customer', 'reference customer'),
> Field('description', 'text'),
> format=lambda r: '%s %s-%s-%s' % (r.customer.first_name,
> r.customer.last_name,
> r.court.branch.address,
> r.court.court_no))
>
>
> *e.g. not work*
> db.define_table('booking',
> Field('scheduled_start', 'datetime'),
> Field('due_date', 'datetime'),
> Field('court', 'reference court'),
> Field('customer', 'reference customer'),
> Field('description', 'text'),
> format=lambda r: '%s %s-%s-%s' % (r.customer.first_name,
> r.customer.last_name,
> r.court.branch.address,
> r.court.court_no))
>
> db.define_table('check_in',
> Field('is_booking', 'boolean'),
> Field('booking', 'reference booking'),
> Field('court', 'reference court'),
> Field('customer', 'reference customer'),
> Field('description', 'text'),
> format=lambda r: '%s %s-%s-%s' % (r.customer.first_name,
> r.customer.last_name,
> r.court.branch.address,
> r.court.court_no))
>
> thank you very much in advance
>
--
---
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.