[Zope-DB] Change login for database connection

Thomas_Janke@prisma-edv.de Thomas_Janke@prisma-edv.de
Tue, 18 Sep 2001 08:52:46 +0200



Thomas_Janke@prisma-edv.de wrote:

>
>
>Hi,
>
>I would like to present the user of a database a form where he enters his
>database user name and pass. This information shall be used to establisch
a
>connection to the database. It is necessary, because most of the logic of
>the database should be in the database itself and not inside the
>Web-interface.
>
>Alternatively, I would like to know, how to close and establish a
>connection from a DTML-document/method or a python_script. And how to
alter
>the properties of a database connection object in between.
>
>Thank you so much for any help.
>


"Matthew T. Kromer" <matt@zope.com> wrote

>Currently, Zope does not make this easy to do; you
>essentially need to
>augment the code to create and cache connections on a > > >per-user rather
>than per-thread basis. What you could do is create a new >type of DB
>connection object, which implemented a smart cache of >credentials &
>connection pools, and correlate this with some data >maintained by a
>session manager.  I dont know if anyone has done something >like this.  I
>suspect a few people have, but the general reluctance is >that this
>usually increases the number of open connections to the >database by a
LOT.

>The reason for that, of course, is to be useful, the >connection cannot
>be closed after a Zope transaction ends, rather, it must be >cached.
> Since each Zope thread receives private copies of objects >from the
>ZODB, the DB connection objects must be managed outside of >the ZODB, so
>you can share them between threads (this sounds tough, but >it really
>isnt -- it just implies the use of some common object which >is not
>persistant.)  Still, a normal connection setup has 1 >connection per
>thread; say 4 per server.  Having one connection per user >means a much
>higher number of connections.   Since many licenses are >based on a
>concurrent-user basis, this means higher expense.  There is >a
>co-incident rise in the amount of DB resources consumed to >mantain these
>connections, as well.


Thank you very much for sharing your knowledge. I'm a sort of newby, just
working with ZOPE for 2 weeks now. And for me, not having anything to to
with Python so far, it is a tough problem to create a new database
connection object. But I feared that I would have to do so.

So if anybody knows about a project which tackles this problem, please let
me know.

Thanks
Thomas