Re: psycopg2 vs psycopg1: the _v_database_connection problem in Zope 2

Federico Di Gregorio <fog-NGVKUo/i/[email protected]>
Newsgroups gmane.comp.python.db.psycopg.devel
Organization initd.org
Message-ID <[email protected]>
Il giorno mer, 24/09/2008 alle 10.13 +0200, Marco Bizzarri ha scritto:
> On Wed, Sep 24, 2008 at 9:43 AM, Federico Di Gregorio <fog-NGVKUo/i/[email protected]> wrote:
> >> - instead of using an _v_ attribute uses a module level, thread
> >> indexed dictionary, storying connections to the database
> >> - each time needs a connection gets that from there
> >>
> >> As usual, I will have to use locks and  try/finally to avoid
> >> concurrent access to that, but that's all, more or less.
> >>
> >> Right?
> >
> > My suggestion is to switch to psycopg2 and modify the connection pool to
> > keep used connections in a dictionary indexed by persistent keys (a
> > serial number is fine). Then you store the connection in the _v_
> > attribute and the connection index in a persisten attribute. If at any
> > time the _v_ attribute does not exists you check the serial number and
> > recover the connection from the pool using it. This should work and
> > solve all problems.
> >
> > federico
> >
> 
> Looks like in the end I have to switch to psycopg2 ;)
> 
> Ok, I will do that... I think the planets have the right alignment.
> 
> But I do not understand what you're meaning about the persistent
> attribute. Can you explain it?

An attribute that does not start with _v_.

federico

-- 
Federico Di Gregorio                         http://people.initd.org/fog
Debian GNU/Linux Developer                                [email protected]
INIT.D Developer                                           fog-NGVKUo/i/[email protected]
 I did appreciate the irony that I was whining about encoding issues on
  a mailing list that was unable to show those chars, too.
                                -- Antti S. Lankila to mono-devel-list@

_______________________________________________
Psycopg mailing list
Psycopg-IAPFreCvJWPBWskQ1e/[email protected]
http://lists.initd.org/mailman/listinfo/psycopg
signature.asc (application/pgp-signature, 197 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEABECAAYFAkjZ9tUACgkQvcCgrgZGjeu0yACfZY01pJdKeBgyHzy5WARAnp5w
X0gAn3w3MUSJB6TFpU5a+Oom9gjXgIYO
=+r1w
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.