> db.define_table('tableaa', Field('afield', 'string', required=True ),
> Field('bfield', 'string', required=True ),
> )
> db.tableaa.virtfield = Field.Virtual( lambda row: XML("<strong>" +
> row.tableaa.afield + '</strong><br> ' + row.tableaa.bfield ))
>
> When this something is a virtual field, as is the case then the two fields
> it concatenates need to be in every query I select from that table or I get
> an error regardless of whether the virtual field is in the list of selected
> fileds or not.
>
You could re-write the virtual field function so it doesn't fail when one
or both of the required fields are missing:
def virtfield(row):
try:
return CAT(STRONG(row.tableaa.afield), BR(), STRONG(row.tableaa.
bfield))
except:
return ''
db.tableaa.virtfield = Field.Virtual(virtfield)
Anthony
--
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.