On Monday, November 2, 2015 at 12:21:53 PM UTC-5, Carlos Cesar Caballero 
wrote:
>
> Antony, thanks for your answer, there were some things I did not know you 
> could do, but there is just a problem with:
>
> db.define_table('review',
>    Field('author'),
>    Field('valuea', 'int'),
>    Field('valueb', 'int'),
>    Field('valuec', 'int'),
>    Field('place','reference place'))
>
> def get_review_average(row):
>     # all the code...
>     # ...
>     return value
> db.review.value = Field.Virtual('value', get_review_average),
>
> As you can see in https://github.com/web2py/pydal/issues/304 there is a 
> problem setting method and field attributes directly.
>

The above will work, and there is no problem setting virtual field 
attributes directly. The problem in the linked issue was only calling a 
method field from within a virtual field (and I'm not sure ORMs tend to 
have the equivalent of virtual fields anyway, so probably not much of a 
limitation, especially given that there are simple workarounds).

One drawback of the above ordering, though, is that it removes the 
"laziness" of the table definition (there is a workaround, but not quite as 
pretty).

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/d/optout.

Reply via email to