diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-06-25 13:12:48 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-06-25 13:12:48 -0400 |
commit | a1a58219c29daf82db425fcdca5ce212d23e4ff8 (patch) | |
tree | d60493b32a7094db489e92063d1c0a0c6f30b446 /lib/sqlalchemy/orm/state.py | |
parent | fc7e74101a9749043196aea017266c23e7ff5577 (diff) | |
download | sqlalchemy-a1a58219c29daf82db425fcdca5ce212d23e4ff8.tar.gz |
turn commit_all into an iterative method
Diffstat (limited to 'lib/sqlalchemy/orm/state.py')
-rw-r--r-- | lib/sqlalchemy/orm/state.py | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/lib/sqlalchemy/orm/state.py b/lib/sqlalchemy/orm/state.py index 52b29a99d..8333d6708 100644 --- a/lib/sqlalchemy/orm/state.py +++ b/lib/sqlalchemy/orm/state.py @@ -435,24 +435,30 @@ class InstanceState(object): - the "modified" flag is set to False - any "expired" markers/callables for attributes loaded are removed. - Attributes marked as "expired" can potentially remain "expired" after this step - if a value was not populated in state.dict. + Attributes marked as "expired" can potentially remain + "expired" after this step if a value was not populated in state.dict. """ + self.commit_all_states([(self, dict_)], instance_dict) - self.committed_state.clear() - self.__dict__.pop('_pending_mutations', None) + @classmethod + def commit_all_states(self, iter, instance_dict=None): + """Mass version of commit_all().""" + + for state, dict_ in iter: + state.committed_state.clear() + state.__dict__.pop('_pending_mutations', None) - callables = self.callables - for key in list(callables): - if key in dict_ and callables[key] is self: - del callables[key] + callables = state.callables + for key in list(callables): + if key in dict_ and callables[key] is state: + del callables[key] - if instance_dict and self.modified: - instance_dict._modified.discard(self) + if instance_dict and state.modified: + instance_dict._modified.discard(state) - self.modified = self.expired = False - self._strong_obj = None + state.modified = state.expired = False + state._strong_obj = None class InspectAttr(object): """Provide inspection interface to an object's state.""" |