summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>2010-09-25 23:55:55 +0100
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>2010-09-25 23:55:55 +0100
commit575b2b5f7724ef349e7d7e76a430d124f474fee0 (patch)
tree1f17685dbed6df2ac85d719f271d70cd7fe74e2b /lib
parent75a6f783c519beb2aae022cf9fff1dc5897e078d (diff)
downloadpsycopg2-575b2b5f7724ef349e7d7e76a430d124f474fee0.tar.gz
The Inet type knows how to adapt itself.
Implemented __conform__ as the Adaptation PEP suggests. It is not required for the type to be registered as adapter.
Diffstat (limited to 'lib')
-rw-r--r--lib/extras.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/extras.py b/lib/extras.py
index 88f85a7..b75eef9 100644
--- a/lib/extras.py
+++ b/lib/extras.py
@@ -423,6 +423,10 @@ class Inet(object):
obj.prepare(self._conn)
return obj.getquoted()+"::inet"
+ def __conform__(self, foo):
+ if foo is _ext.ISQLQuote:
+ return self
+
def __str__(self):
return str(self.addr)
@@ -432,7 +436,6 @@ def register_inet(oid=None, conn_or_curs=None):
_ext.INET = _ext.new_type((oid, ), "INET",
lambda data, cursor: data and Inet(data) or None)
_ext.register_type(_ext.INET, conn_or_curs)
- _ext.register_adapter(Inet, lambda x: x)
return _ext.INET