[Zope-DB] per user connection with SQLRelay

Andreas Kaiser kaiser@xo7.de
31 Jul 2003 23:26:05 +0200


Hi all!


I want to have per-user database connections to Oracle 8/9 from Zope.
The best approach i've found so far was described in a thread on this
list in December 2002:

http://mail.python.org/pipermail/zope-db/2002-December/001176.html

Dieter suggests to use SQLRelay and to 'create a DA variant that
switches users in its "register" method'. 

This is from ZSQLRelayDA/db.py:

  class DB(TM):

    def _begin(self):
        self.con = PySQLRDB.connect(self.host, self.port, 
                                    self.socket,  self.user,
                                    self.password,0,1)
        self.cur = self.con.cursor()

    def _finish(self, *ignored):
        self.con.commit()
        self.con.close()

    def _abort(self, *ignored):
        self.con.rollback()
        self.con.close()

As far as I understand Zope's transaction management, each request
consists (at least) of one transaction and every transaction is
completed within one request.

If this is true, I could provide the authentification arguments to the
PySQLRDB.connect method.

1. Is this true?

2. How can I get the needed values? I'm for sure totally blind, but I
   really don't see how to access them from this class/method...


tia,
Andreas