Re: Fix for retry on serialization errors for PsycopgDA

"Ross J. Reedstrom" <reedstrm-OhmvVRJSr/[email protected]>
Newsgroups gmane.comp.python.db.psycopg.devel
Message-ID <[email protected]>
On Wed, Nov 25, 2009 at 09:42:27PM +0100, Brian Sutherland wrote:
> On Wed, Nov 25, 2009 at 09:07:37PM +0100, Charlie Clark wrote:
> > Am 25.11.2009, 20:48 Uhr, schrieb <psycopg-request-IAPFreCvJWPBWskQ1e/[email protected]>:
> >
> >> ZPsycopgDA/db.py needs an "import logging" at the top. Could you
> >> please add it or remove the calls to logging?
> >
> > Out of interest: what version of Zope are you running?
> 
> 2.9 and I think we'll stick with that for quite some years more.

Hmm, I see this probably the place for my questions. I've been beating
my head against updating a Zope 2 app (2.9.10) from psycopg1 to
psycopg2.
I've got pretty much everything resolved (I enjoyed deleting my own
custom 'convert all these strings to python types' code) except using
Zope DateTime is not behaving well for me. This is using PG 8.3, Zope
2.9.10, Plone 2.5, and psycopg 2.0.13 (under Ubuntu, w/ psycopg inside
buildout, so custom compile)

On any query that attempts to return a timestamptz value, I get:

[...]
  Module Products.ZPsycopgDA.db, line 190, in query
  Module Products.ZPsycopgDA.DA, line 215, in _cast_DateTime
  Module DateTime.DateTime, line 509, in __init__
  Module DateTime.DateTime, line 733, in _parse_args
  Module DateTime.DateTime, line 1111, in _parse
SyntaxError: 2010-01-20 15:36:05-06

(which looks suspiciously like the string representation postgresql
uses)

If I use psycopg2 directly, I get the appropriate datetime object
returned. I'm surprised to see the datetime type being flattened to a
string and reparsed. I'm having a bit of trouble finding how the 'iso'
string passed to _cast_DateTime is being generated. The issue there is
that the  casting method is expecting the timezone as a whitespace
seperated value, in a different format.

Anyone know the trick for making this work?

Ross
-- 
Ross Reedstrom, Ph.D.                                 reedstrm-OhmvVRJSr/[email protected]
Systems Engineer & Admin, Research Scientist        phone: 713-348-6166
The Connexions Project      http://cnx.org            fax: 713-348-3665
Rice University MS-375, Houston, TX 77005
GPG Key fingerprint = F023 82C8 9B0E 2CC6 0D8E  F888 D3AE 810E 88F0 BEDE
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.