[Zope-DB] per user connection with SQLRelay
Matthew T. Kromer
matt@zope.com
Fri Aug 1 14:50:35 EDT 2003
Well, thats the right general idea.
The problem is that when it needs to connect, you're going to have to
lean on an acquisition wrapper somewhere to locate some thread globals
(ie AUTHENTICATED_USER) and grab state based on that user key.
You basically do not have the opportunity to prompt for the SQL userid &
password, so you need to get those values established in advance by
another page, and stored in a persistent object keyed on authenticated
user so you can pick it up later.
Needless to say, I dont like storing passwords, even in memory.
Andreas Kaiser wrote:
>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
>
>
>
>
>_______________________________________________
>Zope-DB mailing list
>Zope-DB@zope.org
>http://mail.zope.org/mailman/listinfo/zope-db
>
>
--
Matt Kromer
Zope Corporation http://www.zope.com/
More information about the Zope-DB
mailing list