diff options
Diffstat (limited to 'lib/sqlalchemy/orm')
| -rw-r--r-- | lib/sqlalchemy/orm/attributes.py | 28 | ||||
| -rw-r--r-- | lib/sqlalchemy/orm/dynamic.py | 9 | 
2 files changed, 25 insertions, 12 deletions
diff --git a/lib/sqlalchemy/orm/attributes.py b/lib/sqlalchemy/orm/attributes.py index e3c6a3512..ce6200e71 100644 --- a/lib/sqlalchemy/orm/attributes.py +++ b/lib/sqlalchemy/orm/attributes.py @@ -355,12 +355,6 @@ class Event(object):          self.op = op          self.parent_token = self.impl.parent_token -    @classmethod -    def _token_gen(self, op): -        @util.memoized_property -        def gen(self): -            return Event(self, op) -        return gen      @property      def key(self): @@ -687,8 +681,17 @@ class ScalarAttributeImpl(AttributeImpl):          state._modified_event(dict_, self, old)          dict_[self.key] = value -    _replace_token = _append_token = Event._token_gen(OP_REPLACE) -    _remove_token = Event._token_gen(OP_REMOVE) +    @util.memoized_property +    def _replace_token(self): +        return Event(self, OP_REPLACE) + +    @util.memoized_property +    def _append_token(self): +        return Event(self, OP_REPLACE) + +    @util.memoized_property +    def _remove_token(self): +        return Event(self, OP_REMOVE)      def fire_replace_event(self, state, dict_, value, previous, initiator):          for fn in self.dispatch.set: @@ -879,8 +882,13 @@ class CollectionAttributeImpl(AttributeImpl):          return [(instance_state(o), o) for o in current] -    _append_token = Event._token_gen(OP_APPEND) -    _remove_token = Event._token_gen(OP_REMOVE) +    @util.memoized_property +    def _append_token(self): +        return Event(self, OP_APPEND) + +    @util.memoized_property +    def _remove_token(self): +        return Event(self, OP_REMOVE)      def fire_append_event(self, state, dict_, value, initiator):          for fn in self.dispatch.append: diff --git a/lib/sqlalchemy/orm/dynamic.py b/lib/sqlalchemy/orm/dynamic.py index b419d2a07..829cda554 100644 --- a/lib/sqlalchemy/orm/dynamic.py +++ b/lib/sqlalchemy/orm/dynamic.py @@ -76,8 +76,13 @@ class DynamicAttributeImpl(attributes.AttributeImpl):              history = self._get_collection_history(state, passive)              return history.added_plus_unchanged -    _append_token = attributes.Event._token_gen(attributes.OP_APPEND) -    _remove_token = attributes.Event._token_gen(attributes.OP_REMOVE) +    @util.memoized_property +    def _append_token(self): +        return attributes.Event(self, attributes.OP_APPEND) + +    @util.memoized_property +    def _remove_token(self): +        return attributes.Event(self, attributes.OP_REMOVE)      def fire_append_event(self, state, dict_, value, initiator,                                                      collection_history=None):  | 
