=======
CHANGES
=======
+0.5beta3
+========
+- orm
+ - Added a new SessionExtension hook called after_attach().
+ This is called at the point of attachment for objects
+ via add(), add_all(), delete(), and merge().
+
0.5beta2
========
- 0.5beta2 includes all bugfixes listed under release
engine level transaction is begun on a connection.
"""
+ def after_attach(self, session, instance):
+ """Execute after an instance is attached to a session.
+
+ This is called after an add, delete or merge.
+ """
class MapperProperty(object):
"""Manage the relationship of a ``Mapper`` to a single class
state.session_id, self.hash_key))
if state.session_id != self.hash_key:
state.session_id = self.hash_key
+ if self.extension is not None:
+ self.extension.after_attach(self, state.obj())
def __contains__(self, instance):
"""Return True if the instance is associated with this session.
log.append('after_flush_postexec')
def after_begin(self, session, transaction, connection):
log.append('after_begin')
+ def after_attach(self, session, instance):
+ log.append('after_attach')
+
sess = create_session(extension = MyExt())
u = User(name='u1')
sess.add(u)
sess.flush()
- assert log == ['before_flush', 'after_begin', 'after_flush', 'before_commit', 'after_commit', 'after_flush_postexec']
+ assert log == ['after_attach', 'before_flush', 'after_begin', 'after_flush', 'before_commit', 'after_commit', 'after_flush_postexec']
log = []
sess = create_session(autocommit=False, extension=MyExt())
u = User(name='u1')
sess.add(u)
sess.flush()
- assert log == ['before_flush', 'after_begin', 'after_flush', 'after_flush_postexec']
+ assert log == ['after_attach', 'before_flush', 'after_begin', 'after_flush', 'after_flush_postexec']
log = []
u.name = 'ed'