Thanks for the info Anthony! I'll try one of those approaches.

Why is validation run before compute?

On Apr 18, 2017 2:50 PM, "Anthony" <[email protected]> wrote:

You should not set "requires" on a computed field -- when you use
validate_and_insert, the validation will be run before the computed value
is generated. However, you can instead set required=True. In that case, any
time you do an insert or update, if the fields needed by the computed field
are missing, the computed field will trigger an exception (you'll have to
catch the exception). Alternatively, you could add IS_NOT_EMPTY validators
to the fields that are needed by the computed field -- as long as those
fields are not empty, neither will the computed field be.

Anthony

On Tuesday, April 18, 2017 at 10:35:06 AM UTC-4, Alfonso Serra wrote:
>
> As per the docs, they say they are stored in db on insert but not computed
> on retrieval. i guess this applies to updates.
> Does this calculate_field function does not return a value in some case?
> for example total = unit * price may be None if the operation fails because
> either unit or price is None or the function does not return any value.
>
>
>
> --
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 a topic in the
Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/
topic/web2py/Kqfg-MG5K44/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
[email protected].
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to