[mod_python] Why can't psycopg2 beta adapt this:

Scott Chapman scott_list at mischko.com
Fri Dec 9 00:52:02 EST 2005


Mod_Python has a StringField class and psycopg2 can't seem to adapt it 
correctly. Type(stringfield_string) shows as:
<class 'mod_python.util.StringField'>

Strings of this class have 3 extra items in dir(stringfield_string) which 
regular strins don't have:
'__dict__', '__module__', 'value'

Here's the class definition from mod_python.util:
class StringField(str):
    """ This class is basically a string with
    a value attribute for compatibility with std lib cgi.py
    """

    def __init__(self, str=""):
        str.__init__(self, str)
        self.value = self.__str__()

How do I make psycopg2 deal with these correctly?  It seems like there's a way 
to make custom "adapters" but I'm rather clueless here.  I just need psycopg2 to 
run str() on the StringField instance and it'd work great.

Cordially,
Scott


More information about the Mod_python mailing list