On Thu, Jul 30, 2009 at 11:44:31AM -0400, Stef Telford wrote: > < decimal = PyImport_ImportModule("decimal"); > --- > > decimal = PyImport_ImportModule("gmpy"); > > Kind of a 'no-brainer' there but, since psycopg is a compiled > extension, I don't see how we can monkey patch the C lib :(
Well, I think it's too low-level. I am sure psycopg is better than that. Python is dynamic, and I'm sure it's possible to find a dynamic way around builtin module names. Let's look around. import psycopg2._psycopg; print dir(psycopg2._psycopg)... aha, types and adapters. There is a DECIMAL type converter, and there is a psycopg2._psycopg.string_types dict where the converter is registered under the key 1700. What 1700? grep 1700 * pgtypes.h:#define NUMERICOID 1700 typecast_builtins.c:static long int typecast_NUMBER_types[] = {20, 23, 21, 701, 700, 1700, 0}; typecast_builtins.c:static long int typecast_DECIMAL_types[] = {1700, 0}; Seems 1700 is a builtin index for DECIMAL type converter. I don't know how exactly type converters are used; I am sure you can find this out by reading psycopgmodule.c or by asking a psycopg mailing list. Probably you need to replace DECIMAL or 1700 type converter, or both. Something like psycopg2._psycopg.DECIMAL = my_decimal_converter or psycopg2._psycopg.string_types[1700] = my_decimal_converter Exact details will require a lot of homework, sure. > Lastly, I have also hacked my version of SQLObject to disable the > local cache, so that SO can use memcache (by subclassing the sqlobject > and then making custom get/setattr methods). It would be nice if there > was a way to toggle the cache on/off at the SO level (if there is, I > haven't found it sadly). There is no way currently. Why not to add it? Extend your hack so it'd be possible to configure caching using a flag in sqlmeta; let's call it useCache = True/False (defaults to True). Publish your patch. Oleg. -- Oleg Broytmann http://phd.pp.ru/ p...@phd.pp.ru Programmers don't die, they just GOSUB without RETURN. ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ sqlobject-discuss mailing list sqlobject-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss