def __set__(self, inst, value): field = self.__field.bind(inst) field.validate(value) if field.readonly and self.__name in inst.__dict__: raise ValueError(self.__name, 'field is readonly') oldvalue = self.queryValue(inst, NO_VALUE) inst.__dict__[self.__name] = value event.sync_notify(FieldUpdatedEvent(inst, field, oldvalue, value))
def set(self, object, value): # Announce that we're going to assign the value to the object. # Motivation: Widgets typically like to take care of policy-specific # actions, like establishing location. event = BeforeObjectAssignedEvent(value, self.__name__, object) sync_notify(event) # The event subscribers are allowed to replace the object, thus we need # to replace our previous value. value = event.object super(Object, self).set(object, value)
def __set__(self, inst, value): field = self.field.bind(inst) field.validate(value) if field.readonly: if self.queryValue(inst, field, _marker) is _marker: field.readonly = False self.setValue(inst, field, value) field.readonly = True return else: raise ValueError(self.__name, 'field is readonly') oldvalue = self.queryValue(inst, field, NO_VALUE) self.setValue(inst, field, value) event.sync_notify(FieldUpdatedEvent(inst, self.field, oldvalue, value))