diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-11-26 23:24:13 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-11-26 23:24:13 -0500 |
commit | 30a50cc46aa836e24ebcbb889cbee583c511af82 (patch) | |
tree | 053c2af8e82434c1e7a616e1a1c55b819aad244b /lib/sqlalchemy/orm/attributes.py | |
parent | 6029496bd3fb78caeab349ef8df5b58f058db16e (diff) | |
download | sqlalchemy-30a50cc46aa836e24ebcbb889cbee583c511af82.tar.gz |
- the wrapped memoized_property here was not working, as the attribute name
didn't match. use straight memoized_props here for now, add a perf test to check it
Diffstat (limited to 'lib/sqlalchemy/orm/attributes.py')
-rw-r--r-- | lib/sqlalchemy/orm/attributes.py | 28 |
1 files changed, 18 insertions, 10 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: |