Thanks a lot for your help Anthony . This worked like a charm.
I chose this since I think it is a more tidy approach - everything that
have to do with database definition is defined in just one place. There
isn't much of an overhead anyway.
Again thanks a lot.
On Friday, October 18, 2013 4:07:34 PM UTC+3, Anthony wrote:
>
>
> 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.