From 5b99ac8fc12b98ddb68eee208f0714be119c6895 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Fri, 22 Sep 2006 22:55:10 +0000 Subject: [PATCH] fix to reset_class_managed to look at noninherited attributes only; an artifact of compilation brought this up --- lib/sqlalchemy/attributes.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/sqlalchemy/attributes.py b/lib/sqlalchemy/attributes.py index af2c908c44..97e2ce7e47 100644 --- a/lib/sqlalchemy/attributes.py +++ b/lib/sqlalchemy/attributes.py @@ -612,6 +612,14 @@ class AttributeManager(object): value = getattr(class_, key, None) if isinstance(value, InstrumentedAttribute): yield value + + def noninherited_managed_attributes(self, class_): + if not isinstance(class_, type): + raise repr(class_) + " is not a type" + for key in class_.__dict__: + value = getattr(class_, key, None) + if isinstance(value, InstrumentedAttribute): + yield value def is_modified(self, object): return object._state.get('modified', False) @@ -668,7 +676,7 @@ class AttributeManager(object): def reset_class_managed(self, class_): """removes all InstrumentedAttribute property objects from the given class.""" - for attr in self.managed_attributes(class_): + for attr in self.noninherited_managed_attributes(class_): delattr(class_, attr.key) def is_class_managed(self, class_, key): @@ -689,6 +697,7 @@ class AttributeManager(object): def register_attribute(self, class_, key, uselist, callable_=None, **kwargs): """registers an attribute at the class level to be instrumented for all instances of the class.""" + #print "register attribute", key, "for class", class_ if not hasattr(class_, '_state'): def _get_state(self): try: -- 2.47.2