As expected, the simple test works. Something else is happening.
In [7]: cpaste
Pasting code; enter '--' alone on the line to stop.
:Base=declarative_base()
:Base.metadata.bind = create_engine('sqlite:///', echo=True)
:class Foo(Base):
: __tablename__ = 'foo'
: id = Column(Integer, primary_key=True)
:Base.metadata.create_all()
:class MyExtension(SessionExtension):
: def after_flush(self, session, context):
: print '*************** MyExtension.after_flush()'
:Session = scoped_session(sessionmaker())
:session = Session()
:print 'extensions before append', session.extensions
:session.extensions.append(MyExtension())
:print 'extensions after append', session.extensions
:session.add(Foo())
:session.flush()
:--
2009-09-10 09:52:09,328 INFO sqlalchemy.engine.base.Engine.0x...43b0 PRAGMA
table_info("foo")
2009-09-10 09:52:09,328 INFO sqlalchemy.engine.base.Engine.0x...43b0 ()
2009-09-10 09:52:09,342 INFO sqlalchemy.engine.base.Engine.0x...43b0
CREATE TABLE foo (
id INTEGER NOT NULL,
PRIMARY KEY (id)
)
2009-09-10 09:52:09,375 INFO sqlalchemy.engine.base.Engine.0x...43b0 ()
2009-09-10 09:52:09,375 INFO sqlalchemy.engine.base.Engine.0x...43b0 COMMIT
extensions before append []
extensions after append [<__main__.MyExtension object at 0x025C48D0>]
2009-09-10 09:52:09,405 INFO sqlalchemy.engine.base.Engine.0x...43b0 BEGIN
2009-09-10 09:52:09,405 INFO sqlalchemy.engine.base.Engine.0x...43b0 INSERT
INTO foo DEFAULT VALUES
2009-09-10 09:52:09,405 INFO sqlalchemy.engine.base.Engine.0x...43b0 []
*************** MyExtension.after_flush()
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---