so that the "listen_for_events.py" example works again.
[ticket:1314]
- When flushing partial sets of objects using session.flush([somelist]),
pending objects which remain pending after the operation won't
inadvertently be added as persistent. [ticket:1306]
+
+ - Added "post_configure_attribute" method to InstrumentationManager,
+ so that the "listen_for_events.py" example works again.
+ [ticket:1314]
- sql
- Fixed missing _label attribute on Function object, others
from sqlalchemy.orm.interfaces import AttributeExtension, InstrumentationManager
class InstallListeners(InstrumentationManager):
- def instrument_attribute(self, class_, key, inst):
+ def post_configure_attribute(self, class_, key, inst):
"""Add an event listener to an InstrumentedAttribute."""
inst.impl.extensions.insert(0, AttributeListener(key))
- return super(InstallListeners, self).instrument_attribute(class_, key, inst)
class AttributeListener(AttributeExtension):
"""Generic event listener.
manager = create_manager_for_cls(cls)
manager.instrument_attribute(key, inst, True)
+ def post_configure_attribute(self, key):
+ pass
+
def uninstrument_attribute(self, key, propagated=False):
if key not in self:
return
if not propagated:
self._adapted.instrument_attribute(self.class_, key, inst)
+ def post_configure_attribute(self, key):
+ self._adapted.post_configure_attribute(self.class_, key, self[key])
+
def install_descriptor(self, key, inst):
self._adapted.install_descriptor(self.class_, key, inst)
key, factory or list)
else:
typecallable = kw.pop('typecallable', None)
-
+
manager[key].impl = _create_prop(class_, key, manager, typecallable=typecallable, **kw)
-
+ manager.post_configure_attribute(key)
+
def register_descriptor(class_, key, proxy_property=None, comparator=None, parententity=None, property_=None):
manager = manager_of_class(class_)
return fn
class InstrumentationManager(object):
- """User-defined class instrumentation extension."""
+ """User-defined class instrumentation extension.
+
+ The API for this class should be considered as semi-stable,
+ and may change slightly with new releases.
+
+ """
# r4361 added a mandatory (cls) constructor to this interface.
# given that, perhaps class_ should be dropped from all of these
def instrument_attribute(self, class_, key, inst):
pass
+ def post_configure_attribute(self, class_, key, inst):
+ pass
+
def install_descriptor(self, class_, key, inst):
setattr(class_, key, inst)