Skip to content

Commit

Permalink
Send FieldUpdatedEvent on Property __set__
Browse files Browse the repository at this point in the history
  • Loading branch information
Lorenzo Buonanno committed Oct 20, 2020
1 parent 8057648 commit f31288e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/grokcore/annotation/lazy.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@
"""

import persistent
from zope import event
import zope.annotation.interfaces
import zope.cachedescriptors.property

from zope.interface import implementer
from zope.location import Location
from zope.schema.fieldproperty import FieldUpdatedEvent
from zope.annotation.interfaces import IAnnotations
from grokcore.annotation.interfaces import IAnnotationFactory

Expand Down Expand Up @@ -57,7 +59,9 @@ def __set__(self, inst, value):
if field.readonly:
raise ValueError(self.__name, 'field is readonly')
field.validate(value)
old_value = inst._load(self.__name, None)
inst._store(self.__name, value)
event.notify(FieldUpdatedEvent(inst, field, old_value, value))

def __getattr__(self, name):
return getattr(self.__field, name)
Expand Down

0 comments on commit f31288e

Please sign in to comment.