diff -r b2d0b14a365d -r 394f853bb653 server/hook.py --- a/server/hook.py Mon Dec 07 17:57:19 2009 +0100 +++ b/server/hook.py Mon Dec 07 19:14:49 2009 +0100 @@ -87,6 +87,19 @@ VRegistry.REGISTRY_FACTORY['hooks'] = HooksRegistry +def entity_oldnewvalue(entity, attr): + """returns the couple (old attr value, new attr value) + NOTE: will only work in a before_update_entity hook + """ + # get new value and remove from local dict to force a db query to + # fetch old value + newvalue = entity.pop(attr, None) + oldvalue = getattr(entity, attr) + if newvalue is not None: + entity[attr] = newvalue + return oldvalue, newvalue + + # some hook specific selectors ################################################# @objectify_selector