Hello,

(sorry if the question was already asked, but searching the term "engine" in the archives was complicated with the name pollution caused
by the sf.net sponsors....)

In short: I'm developing a web based application (written in zope3) which needs to use different database credentials depending on the application credentials which may obviosly vary between requests even for the same thead. (because I have an existing security framework on the sql server and triggers that logs the username that modifies rows etc)

I wouldn't like to recreate a new engine, associated tables and mappers for every new request. I see some possible paths:

1) managing a pool of engines,mappers and tables kept in a dictionary mapped by application user. (subsuboptimal solution)

2) creating a wrapper for engine that proxies itself to the correct engine appropriated for the current request. However I'm not sure whether the engine object is traversed for each access to the connection or some attributes of the connection are saved inside
   table,mapper etc objects

3) somehow hooking the db connection pool used by the underlining engine in such a way that it transparenty chooses the dbapi connection appropriate for the application credential currently processed by the thread. I see that the SingletonThreadPool.do_get() method access a dictionary ("_conns"). Perhaps it would be possible to put a specific connection there before each request processing but I don't like fiddling with "private" attributes.


Also changing the underlining connection/engine may intefere with the objectstore? What should I do before and after a request processing (assuming request doesn't span connection boundaries) in order to insure consistency without too much overhead?


is there a preferred way to doing this?


marko


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to