I don't get it, but this code doesn't call after_flush/before_flush/after_flush_postexec
# -*- coding: utf-8 -*-
from sqlalchemy.orm import scoped_session, sessionmaker
from sqlalchemy.orm.interfaces import SessionExtension
class AfterFlushExtension(SessionExtension):
def before_commit(self, session):
print "> before_commit"
def after_commit(self, session):
print "> after_commit"
def before_flush(self, session, flush_context, instances):
print '> before_flush'
def after_flush(self, session, flush_context):
print '> after_flush'
def after_flush_postexec(self, session, flush_context):
print '> after_flush_postexec'
session = scoped_session(sessionmaker(extension=AfterFlushExtension()))
session.flush()
session.commit()
And a result:
$ python ~/Dropbox/playground/python/sqlalchemy_hook_test/main.py
> before_commit
> after_commit
Thank you.--
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/40uHGUoHJ1sJ.
To post to this group, send email to sqlal...@googlegroups.com.
To unsubscribe from this group, send email to sqlalchemy+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.