[Zope-DB] FYI: Pickling

Gerhard Häring gerhard@bigfoot.de
Thu, 27 Sep 2001 05:43:00 +0200

On Mon, Sep 24, 2001 at 07:34:08AM +0200, Gerhard Häring wrote:
> On Mon, Sep 24, 2001 at 07:21:00AM +0200, Gerhard Häring wrote:
> > [...] Now I get a very obscure error in ZODB. But only when the first column
> > is an integer.
> > 
> > In case this rings any bells: an UnpickleableError is raised. [...]

I've meanwhile solved the pickling problem. This might be old news for you, but
it certainly was news for me: I found out I can pickle the extension types from
pyPgSQL (in fact, anything), I just have to use the copy_reg module, like so:

def PgInt8_reduce(i8):
    return PgInt8_construct, tuple([str(i8)])

def PgInt8_construct(args):
    return PgSQL.PgInt8(args[0])

copy_reg.pickle(PgSQL.PgInt8Type, PgInt8_reduce, PgInt8_construct)

I'm glad I could avoid casting everything to Python types like long, etc.

mail:   gerhard <at> bigfoot <dot> de       registered Linux user #64239
web:    http://www.cs.fhm.edu/~ifw00065/    OpenPGP public key id 86AB43C0
public key fingerprint: DEC1 1D02 5743 1159 CD20  A4B6 7B22 6575 86AB 43C0
reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b')))