Session gets a flag "external_connection" or something like that which means it will interrupt the engine's current connection with a new one from the pool, and use that for committing, also replacing it as the "current connection" upon push()/pop() so that select statements within mapper use this new connection as well, if they call mapper.using(sess).
basically, need to be able to say s = Session(), where s will not participate with the current thread's connection, transactionalized or not. so engine needs to support this pattern at an abstracted level (i.e., so that all selects/execs etc. can partcipate). this is def. a hibernate thing which has everything more localized to an explicit session....
this will need something on engine like start_nested()/end_nested() that interrupts the transaction going on, if any, or the current thread local connection...connection pool should now have use_threadlocal turned off, SingletonPool will have to be improved to support real pooled behavior, the current thread management will be handled by the engine. Session will have to use these with a push/pop, also within a commit(), and somehow have those two use the same nested() if they are used together
general idea is:
s = Session(external_connection=True) x = MyObj(_sa_session = s) y = MyObj() engine.begin() y.etc s.commit() # commits s, readable in the DB now objectstore.commit() engine.rollback()
this is important stuff since engine conflates the concepts of "database identity" with "connection/session", sorta like how mapper conflates "class structutre" with "query generation"...the concept of Sessions, ORM or no, needs to be nailed down better.