[Twisted-Python] Query output from pyPgSQL via Perspective Broker, how?

Nicola Larosa nico at tekNico.net
Wed Oct 20 04:26:22 EDT 2004

This is a pyPgSQL-Twisted mixed question, I post it here because I recently
saw Gerard Haering posting, hi Gerard. :-)

I'm trying to remotely send the PostgreSQL query output from pyPgSQL via
Perspective Broker, and finding it difficult to prevent all the
InsecureJelly exceptions. I'm trying to avoid modifying hundreds of already
written queries, and I'm patching pyPgSQL instead (albeit at runtime).

A first problem is that the make_PgResultSetClass factory function
dinamically builds a subclass of the PgResultSet class, making it
impossible to statically subclass it with pb.Copyable and pb.RemoteCopy . I
worked around that making the make_PgResultSetClass return an object of the
PgResultSet class, instead of a new subclass. This seems to work.

Now I'm fighting against all the pyPgSQL special types. I'm changing the
typecast method in the TypeCache class to return only standard types, and
while it works fine for number and strings, it seems that mx.DateTime and
PG_INET values are not intercepted.

I convert the mx.DateTime and mx.DateTimeDelta instances into standard
datetime and timedelta ones, since the Twisted docs says PB already knows
those. I also added a check for PG_INET, returning str(value) in that case.
I'm still getting InsecureJelly exceptions for these two data types,

I feel like I'm following the tough road doing this, maube there's a simpler
way of achieving what I need. Any suggestions? Thanks in advance.

[P.S.: the .sig was not manually chosen, just happened. ;-) ]

Nicola Larosa - nico at tekNico.net

With Twisted, you don't need threads. You don't want threads. Threads 
are actually harmful: http://www.kuro5hin.org/story/2002/11/18/22112/860
 -- Jonathan Lange, August 2004

More information about the Twisted-Python mailing list