[Zope3-checkins] CVS: Products3/pypgsqlda - adapter.py:1.3

Christian Theune ct@gocept.com
Mon, 17 Mar 2003 16:24:10 -0500


Update of /cvs-repository/Products3/pypgsqlda
In directory cvs.zope.org:/tmp/cvs-serv32206

Modified Files:
	adapter.py 
Log Message:
added preparation for type converters (thanks to Tiran for 
putting the list of types together)


=== Products3/pypgsqlda/adapter.py 1.2 => 1.3 ===
--- Products3/pypgsqlda/adapter.py:1.2	Mon Mar 17 12:37:41 2003
+++ Products3/pypgsqlda/adapter.py	Mon Mar 17 16:24:09 2003
@@ -42,4 +42,66 @@
                             host=conn_info['host'], 
                             unicode_results=1, 
                             client_encoding=client_encoding)
+                            
+    def getConverter(self, typechar):
+        if converter_mapping.has_key(str(typechar)):
+            return converter_mapping[str(typechar)]
+        else:
+            return identity
 
+# Converters
+
+def convertInterval(data):
+    import pdb;
+    pdb.set_trace()
+    print data
+
+# types from pypgsql/libpqmodule.c        
+converter_mapping = {
+        'abstime' : identity,       # PG_ABSTIME
+        'aclitem' : identity,       # PG_ACLITEM
+        'blob' : identity,          # PG_BLOB
+        'bool' : identity,          # PG_BOOL
+        'box' : identity,           # PG_BOX
+        'char' : identity,          # PG_BPCHAR
+        'bytea' : identity,         # PG_BYTEA
+        'money' : identity,         # PG_CASH
+        'char' : identity,          # PG_CHAR
+        'cid' : identity,           # PG_CID
+        'cidr' : identity,          # PG_CIDR
+        'circle' : identity,        # PG_CIRCLE
+        'date' : identity,          # PG_DATE
+        'float4' : identity,        # PG_FLOAT4
+        'float' : identity,         # PG_FLOAT8
+        'inet' : identity,          # PG_INET
+        'int2' : identity,          # PG_INT2
+        'int2vector' : identity,    # PG_INT2VECTOR
+        'integer' : identity,       # PG_INT4
+        'bigint' : identity,        # PG_INT8
+        'interval' : identity,      # PG_INTERVAL
+        'line' : identity,          # PG_LINE
+        'lseg' : identity,          # PG_LSEG
+        'macaddr' : identity,       # PG_MACADDR
+        'name' : identity,          # PG_NAME
+        'numeric' : identity,       # PG_NUMERIC
+        'oid' : identity,           # PG_OID
+        'oidvector' : identity,     # PG_OIDVECTOR
+        'path' : identity,          # PG_PATH
+        'point' : identity,         # PG_POINT
+        'polygon' : identity,       # PG_POLYGON
+        'refcursor' : identity,     # PG_REFCURSOR
+        'regproc' : identity,       # PG_REGPROC
+        'reltime' : identity,       # PG_RELTIME
+        'rowid' : identity,         # PG_ROWID
+        'text' : identity,          # PG_TEXT
+        'tid' : identity,           # PG_TID
+        'time' : identity,          # PG_TIME
+        'timestamp' : identity,     # PG_TIMESTAMP
+        'timestamptz' : identity,   # PG_TIMESTAMPTZ
+        'tinterval' : identity,     # PG_TINTERVAL
+        'unknown' : identity,       # PG_UNKNOWN
+        'varbit' : identity,        # PG_VARBIT
+        'varchar' : identity,       # PG_VARCHAR
+        'xid' : identity,           # PG_XID
+        'zpbit' : identity          # PG_ZPBIT
+    }