allow properties w/ setters to work with persistable classes

This commit is contained in:
Jeremy Penner 2011-09-11 21:43:37 -04:00
parent 1ca029e2b6
commit 734b38f66c

View file

@ -81,6 +81,10 @@ class TPrs(object):
__obj_setattr = object.__setattr__ __obj_setattr = object.__setattr__
__obj_delattr = object.__delattr__ __obj_delattr = object.__delattr__
def __setattr__(self, key, value): def __setattr__(self, key, value):
prop = getattr(self.__class__, key, None)
if isinstance(prop, property) and prop.fset:
prop.fset(self, value)
return
try: try:
if self._fWriteToPersistent or key in self._persistent: if self._fWriteToPersistent or key in self._persistent:
self._persistent[key] = value self._persistent[key] = value