[Zope3-checkins] CVS: Products3/pypgsqlda - adapter.py:1.4
Christian Theune
ct@gocept.com
Tue, 18 Mar 2003 15:00:17 -0500
Update of /cvs-repository/Products3/pypgsqlda
In directory cvs.zope.org:/tmp/cvs-serv13178
Modified Files:
adapter.py
Log Message:
added proposed types where to convert things into
=== Products3/pypgsqlda/adapter.py 1.3 => 1.4 ===
--- Products3/pypgsqlda/adapter.py:1.3 Mon Mar 17 16:24:09 2003
+++ Products3/pypgsqlda/adapter.py Tue Mar 18 15:00:17 2003
@@ -52,56 +52,71 @@
# Converters
def convertInterval(data):
+ """Returns the length of the interval in seconds."""
+ return data.seconds
+
+def convertBool(data):
+ """Returns a boolean as normal python boolean."""
+ return not not data
+
+def convertMac(data):
+ """Return a Mac as a normal string."""
+ return unicode(data)
+
+def convertNet(data):
+ """Return a network address as tuple (network, mask)."""
+ return unicode(data).split('/')
+
+def debug(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
+ 'abstime' : debug, # PG_ABSTIME time
+ 'aclitem' : debug, # PG_ACLITEM unicode
+ 'blob' : debug, # PG_BLOB string
+ 'bool' : convertBool, # PG_BOOL boolean
+ 'box' : debug, # PG_BOX geometric.box
+ 'char' : debug, # PG_BPCHAR identity
+ 'bytea' : debug, # PG_BYTEA
+ 'money' : debug, # PG_CASH float
+ 'cid' : debug, # PG_CID
+ 'cidr' : debug, # PG_CIDR
+ 'circle' : debug, # PG_CIRCLE geometric.circle
+ 'date' : debug, # PG_DATE datetime.date
+ 'float4' : debug, # PG_FLOAT4 float
+ 'float' : debug, # PG_FLOAT8 float
+ 'inet' : debug, # PG_INET unicode
+ 'int2' : debug, # PG_INT2 integer
+ 'int2vector' : debug, # PG_INT2VECTOR
+ 'integer' : debug, # PG_INT4 integer
+ 'bigint' : debug, # PG_INT8 longint
+ 'interval' : convertInterval, # PG_INTERVAL datetime.delta
+ 'line' : debug, # PG_LINE geometric.line
+ 'lseg' : debug, # PG_LSEG geometric.linesegment
+ 'macaddr' : debug, # PG_MACADDR unicode
+ 'name' : debug, # PG_NAME
+ 'numeric' : debug, # PG_NUMERIC float
+ 'oid' : debug, # PG_OID
+ 'oidvector' : debug, # PG_OIDVECTOR
+ 'path' : debug, # PG_PATH geometric.path
+ 'point' : debug, # PG_POINT geometric.point
+ 'polygon' : debug, # PG_POLYGON geometric.polygon
+ 'refcursor' : debug, # PG_REFCURSOR
+ 'regproc' : debug, # PG_REGPROC
+ 'reltime' : debug, # PG_RELTIME
+ 'rowid' : debug, # PG_ROWID
+ 'text' : debug, # PG_TEXT unicode
+ 'tid' : debug, # PG_TID
+ 'time' : debug, # PG_TIME datetime.time
+ 'timestamp' : debug, # PG_TIMESTAMP datetime.datetime
+ 'timestamptz' : debug, # PG_TIMESTAMPTZ datetime.datetime
+ 'tinterval' : debug, # PG_TINTERVAL datetime.delta
+ 'unknown' : debug, # PG_UNKNOWN
+ 'varbit' : debug, # PG_VARBIT
+ 'varchar' : debug, # PG_VARCHAR unicode
+ 'xid' : debug, # PG_XID
+ 'zpbit' : debug # PG_ZPBIT
}