Hello, I've tried your suggestion and worked!. At 'before_update' stored old values in request.vars using Set object, then at 'after_update' access these values and compare to the new ones at f.
Note: if you use 'detect_record_change=True' it seems 'before_update' is called twice, though it doesn't matter in my case. I use it to be sure things don't mess when user click on back button of the browser or when concurrent access to the same record edition. FYI my 'after_update' alters others tables and/or send websocket messagges depending on which fields have changed on the actual table. Thanks! El martes, 1 de abril de 2014 18:09:03 UTC+2, Anthony escribió: > > _after_update of course runs *after* the records have been updated in the > database, so if you use the Set to check those records in the _after_update > callback, they will therefore now have the new values. How could it be any > other way? Accessing the Set in the _after_update callback can still be > useful, even though it does not enable you to access the old values. > > Note, when records are updated, they are not first retrieved from the > database, so the DAL does not even know the original values of the updated > records. > > Is it possible you could do what you need via the _before_update > callbacks? If not, perhaps in the _before_update callback you could > retrieve the records based on the Set and store them in an object in the > global environment, and then have _after_update read the records you have > stored. What exactly does your _after_update do? > > Anthony > > On Tuesday, April 1, 2014 9:39:57 AM UTC-4, mcamel wrote: > >> Hello, >> >> I'm trying to get a solid way of triggering an action, "after" an update, >> based on the data "before" the update. >> >> One approach is building an SQLFORM, inject the old values as hidden >> fields, validate it and do the update and triggers manually, but then you >> are limited to use this FORM (it wouldn't work the same if you edit the >> record on a grid, e.g.). >> >> Theoretically, the safer and "universal" way is with 'after_update' >> callback, as in: >> >> >> http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#before-and-after-callbacks >> >> I imagined the Set accesing these old values, but that's true only for >> 'before_update' callback. These was a surprise because i cannot find any >> difference from the record of field values, except the id, but this could >> be passed explicitly as it is done in 'after_insert' callback. >> >> So, what's the purpose of the Set in 'after_update', then?. And, is there >> another way to obtain the old values?. >> >> Regards. >> > -- 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.

