diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/sqlalchemy/orm/attributes.py | 5 | ||||
| -rw-r--r-- | lib/sqlalchemy/orm/interfaces.py | 13 |
2 files changed, 12 insertions, 6 deletions
diff --git a/lib/sqlalchemy/orm/attributes.py b/lib/sqlalchemy/orm/attributes.py index 2d7c726a1..e67026eea 100644 --- a/lib/sqlalchemy/orm/attributes.py +++ b/lib/sqlalchemy/orm/attributes.py @@ -1545,7 +1545,10 @@ class InstrumentationRegistry(object): def state_of(self, instance): if instance is None: raise AttributeError("None has no persistent state.") - return self.state_finders[instance.__class__](instance) + try: + return self.state_finders[instance.__class__](instance) + except KeyError: + raise AttributeError("%r is not instrumented" % instance.__class__) def state_or_default(self, instance, default=None): if instance is None: diff --git a/lib/sqlalchemy/orm/interfaces.py b/lib/sqlalchemy/orm/interfaces.py index ff15062aa..6dd2225c8 100644 --- a/lib/sqlalchemy/orm/interfaces.py +++ b/lib/sqlalchemy/orm/interfaces.py @@ -702,17 +702,20 @@ class PropertyOption(MapperOption): return l class AttributeExtension(object): - """An abstract class which specifies `append`, `delete`, and `set` - event handlers to be attached to an object property. + """An event handler for individual attribute change events. + + AttributeExtension is assembled within the descriptors associated + with a mapped class. + """ - def append(self, obj, child, initiator): + def append(self, state, value, initiator): pass - def remove(self, obj, child, initiator): + def remove(self, state, value, initiator): pass - def set(self, obj, child, oldchild, initiator): + def set(self, state, value, oldvalue, initiator): pass |
