cubicweb #1060431 [entity_oldnewvalue] returns weird stuff [resolved]

the contract of Hook.entity_oldnewvalue is a bit complicated since if the attribute is not modified, it will return:

  • oldvalue: the old value
  • newvalue: a _marker (object())

which is not completely intuitive and forces the hook programmer to defensively write:

if 'attr' in entity.edited_attributes:
    old, new = self.entity_oldnewvalue
    if old != new:
done in3.8.5
load left0.000
closed by<not specified>