Andreas Jung wrote:
--On 19. Dezember 2005 15:32:46 +0100 Pier Luigi Fiorini <pierluigi.fiorini@yacme.com> wrote:
Hello, I'm developing a Zope application that uses a PostgreSQL connection and several ZSQL objects. People should log in using a Postgres user and ZSQL object should be executed by the user that's logged in. Multiple people can be logged at the same time. Unfortunately it is not possible because the same Postgres connection is used by all the ZSQL object. Is there a way to change the user executing a ZSQL query?
The short version: forget it. DA connections are tied to a particular user. Connections are persistent and shared across threads and requests. You really don't want to connect/re-connect for every request and user. You would have to implement your own connection management including connection pooling *somehow*.
I would also be interested in multiuser ZSQLs, though it's not my main goal and I don't expect participating on such coding. Provided there wont be thousands of users (mine number is just about 20), how about to create a pool of connections in some ZODB folder, simply identified as sqlconn_jack, sqlconn_john, sqlconn_martin, ... and teach ZSQLMethod to select appropriate connection upon request? SQL connections currently support auto-connection upon request, so a timeout disconnection would be nice added feature in this case, but for small number of users it does not seem to be necessary. I think this would be a considerable, but easily implemented, step to obtain SQL userbase binding. Is there a problem somewhere? -- \//\/\