diff options
| -rw-r--r-- | src/pyramid/decorator.py | 4 | ||||
| -rw-r--r-- | src/pyramid/util.py | 13 |
2 files changed, 7 insertions, 10 deletions
diff --git a/src/pyramid/decorator.py b/src/pyramid/decorator.py index 89cbb0f6e..525111ccd 100644 --- a/src/pyramid/decorator.py +++ b/src/pyramid/decorator.py @@ -41,5 +41,9 @@ class reify(object): if inst is None: return self val = self.wrapped(inst) + # reify is a non-data-descriptor which is leveraging the fact + # that it is not invoked if the equivalent attribute is defined in the + # object's dict, so the setattr here effectively hides this descriptor + # from subsequent lookups setattr(inst, self.wrapped.__name__, val) return val diff --git a/src/pyramid/util.py b/src/pyramid/util.py index fb8608512..bc589b36f 100644 --- a/src/pyramid/util.py +++ b/src/pyramid/util.py @@ -74,6 +74,8 @@ def as_sorted_tuple(val): class SettableProperty(object): + # this is just like reify but does not store the computed result on + # the class such that subsequent invocations invoke the callable again def __init__(self, wrapped): self.wrapped = wrapped functools.update_wrapper(self, wrapped) @@ -81,16 +83,7 @@ class SettableProperty(object): def __get__(self, obj, type=None): if obj is None: # pragma: no cover return self - value = obj.__dict__.get(self.wrapped.__name__, _marker) - if value is _marker: - value = self.wrapped(obj) - return value - - def __set__(self, obj, value): - obj.__dict__[self.wrapped.__name__] = value - - def __delete__(self, obj): - del obj.__dict__[self.wrapped.__name__] + return self.wrapped(obj) class InstancePropertyHelper(object): |
