[hooks] entity_oldnewvalue should never return _MARKER: if the attribute isn't in the entity dict (hence unmodified), return the old value stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 14 Jun 2010 18:58:03 +0200
branchstable
changeset 5744 6b2a987370e8
parent 5741 bbef88618fbb
child 5745 d532fe79800b
[hooks] entity_oldnewvalue should never return _MARKER: if the attribute isn't in the entity dict (hence unmodified), return the old value
server/hook.py
--- a/server/hook.py	Fri Jun 11 18:48:17 2010 +0200
+++ b/server/hook.py	Mon Jun 14 18:58:03 2010 +0200
@@ -122,6 +122,7 @@
 _MARKER = object()
 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
@@ -130,6 +131,8 @@
     oldvalue = getattr(entity, attr)
     if newvalue is not _MARKER:
         entity[attr] = newvalue
+    else:
+        newvalue = oldvalue
     return oldvalue, newvalue