diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2009-01-03 22:15:38 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2009-01-03 22:15:38 +0000 |
| commit | 653191d913b980964d45b4ef92ed6a0b5d95af91 (patch) | |
| tree | 1b9fdbd015ff16d086a9156ea75339a84f7c9c73 /lib/sqlalchemy/orm/attributes.py | |
| parent | 88a799379fa57f4c220c9cbad89cf7d407147d0b (diff) | |
| download | sqlalchemy-653191d913b980964d45b4ef92ed6a0b5d95af91.tar.gz | |
added teardown_instance() to complement setup_instance().
Based on the instance/class agnostic behavior of ClassManager, this might be the best we can
do regarding [ticket:860]
Diffstat (limited to 'lib/sqlalchemy/orm/attributes.py')
| -rw-r--r-- | lib/sqlalchemy/orm/attributes.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/sqlalchemy/orm/attributes.py b/lib/sqlalchemy/orm/attributes.py index 2b2760208..5c242aa7e 100644 --- a/lib/sqlalchemy/orm/attributes.py +++ b/lib/sqlalchemy/orm/attributes.py @@ -1269,6 +1269,9 @@ class ClassManager(dict): def setup_instance(self, instance, state=None): setattr(instance, self.STATE_ATTR, state or self.instance_state_factory(instance, self)) + + def teardown_instance(self, instance): + delattr(instance, self.STATE_ATTR) def _new_state_if_none(self, instance): """Install a default InstanceState if none is present. @@ -1381,6 +1384,9 @@ class _ClassInstrumentationAdapter(ClassManager): state.dict = self._adapted.get_instance_dict(self.class_, instance) return state + def teardown_instance(self, instance): + self._adapted.remove_state(self.class_, instance) + def state_of(self, instance): if hasattr(self._adapted, 'state_of'): return self._adapted.state_of(self.class_, instance) |
