This is largely discussed at your answer on StackOverflow, but I'll summarize here.
Using the @observableMethod decorator on a method that is part of a property doesn't work in (c)python 3.5. Some problem occurs when the property is correctly bound to the class instance. For example,
class Bar(object):
def __init__(self):
self._bbb = "bar"
@property
def bbb(self):
return self._bbb
@bbb.setter
@observable_method
def setbbb(self, value):
self._bbb = value
will cause the following error when you create an instance of Bar and try to set bar.bbb
Traceback (most recent call last):
File "", line 1, in
TypeError: 'ObservableMethodManager_PersistOnInstances' object is not callable
Using explicit properties as below causes the same issue:
class Bar(object):
def __init__(self):
self._bbb = "bar"
def getbbb(self):
return self._bbb
@observable_method
def setbbb(self, value):
self._bbb = value
bbb = property(getbbb, setbbb)
Interestingly, a hackneyed attempt where the property is completely distinct from the class doesn't have the issue. The following works:
class Bar(object):
def __init__(self):
self._bbb = "bar"
def getbbb(self):
return self._bbb
@observable_method
def setbbb(self, value):
self._bbb = value
b = Bar()
prop = property(Bar.getbbb)
prop = prop.setter(Bar.setbbb)
def cb(val):
print("Called, {0}".format(val))
b.setbbb.add_observer(cb)
# >>> True
prop.__get__(b)
# >>> 'bar'
prop.__set__(b, 'BAR')
# >>> Called, BAR
b._bbb
# >>> 'BAR'
This is largely discussed at your answer on StackOverflow, but I'll summarize here.
Using the
@observableMethoddecorator on a method that is part of a property doesn't work in (c)python 3.5. Some problem occurs when the property is correctly bound to the class instance. For example,will cause the following error when you create an instance of Bar and try to set
bar.bbbUsing explicit properties as below causes the same issue:
Interestingly, a hackneyed attempt where the property is completely distinct from the class doesn't have the issue. The following works: