I'm implementing database session variables (in Oracle, 
DBMS_SESSION.SET_CONTEXT(...)), in order to be able to set (from 
sqlalchemy) and retrieve (from a database trigger) the application userid 
and URL path during table audit triggers.

The tricky bit is that if I set the user to 'user1', that remains in the 
session in the database even when a different sqlalchemy thread grabs that 
same session from the connection pool.  I want to prevent the wrong 
information accidentally still being in the session, so I want to be sure 
to reset it when appropriate and I'm wondering whether checkout from the 
Pool is the event you would recommend?

    @event.listens_for(engine, 'checkout')
    def receive_checkout(dbapi_connection, connection_record, 
connection_proxy):

If the same database session is recycled from the connection pool, will it 
have the same *connection_record*?  I'd prefer to record the fact that I've 
set the database session's variables on an object (such as 
connection_record) so that subsequent requests can detect whether it needs 
to be reset.  Will connection_record correspond to a database session?

Thanks in advance for any advice here.
Kent



-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to