OK, think I've solved it.

The documentation says a dict passed is into the _before_insert - seems 
it's a list of lists of [field, value]. I can manipulate the list and the 
result is what gets written.

So perfect - I can do what I need, just I think the documentation needs 
checking (or I need correcting)

Here's the definition I have which I think is all standard?:
db.income_line_item._before_insert.append(lambda f: 
trigger_ili_before_insert(f))

On Thursday, May 28, 2015 at 7:16:55 AM UTC+2, Ian Ryder wrote:
>
> Hi, I'd like to modify the data on a record before it is inserted / 
> updated. I was hoping I could do this with _before_insert / update but I 
> don't think it's possible.
>
> As an example from a previous life, in Salesforce on a before trigger you 
> can change field values in memory on the way into the database and they 
> will automatically get written on completion.
>
> Am I right in thinking with web2py it's just a set of data in its own 
> world that you can do something with? I would need to perform an update on 
> the record after it's been inserted which seems like a waste, especially 
> when dealing with large data sets.
>
> Thanks
> Ian
>

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to