diff options
author | Federico Di Gregorio <fog@initd.org> | 2005-02-28 15:50:55 +0000 |
---|---|---|
committer | Federico Di Gregorio <fog@initd.org> | 2005-02-28 15:50:55 +0000 |
commit | cd672525e10826231576e6eb5ab256df1bfed72c (patch) | |
tree | f6d2add7b330b9c73a950ce6fee0ea9254d12f81 /examples/usercast.py | |
parent | 1ec3c837203661efd9441e2509351156b4a53a40 (diff) | |
download | psycopg2-cd672525e10826231576e6eb5ab256df1bfed72c.tar.gz |
Adaptation fixes (a lot.)
Diffstat (limited to 'examples/usercast.py')
-rw-r--r-- | examples/usercast.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/examples/usercast.py b/examples/usercast.py index 2711709..854e277 100644 --- a/examples/usercast.py +++ b/examples/usercast.py @@ -23,6 +23,12 @@ import sys, psycopg import psycopg.extensions import whrandom +# importing psycopg.extras will give us a nice tuple adapter: this is wrong +# because the adapter is meant to be used in SQL IN clauses while we use +# tuples to represent points but it works and the example is about Rect, not +# "Point" +import psycopg.extras + if len(sys.argv) > 1: DSN = sys.argv[1] @@ -43,7 +49,7 @@ conn.commit() # usually a function, but we use a class, just to demonstrate the # flexibility of the psycopg casting system -class Rect: +class Rect(object): """Very simple rectangle. Note that we use this type as a data holder, as an adapter of itself for @@ -59,7 +65,6 @@ class Rect: def __conform__(self, proto): """This is a terrible hack, just ignore proto and return self.""" - print "CONFORMIG!" return self def from_points(self, x0, y0, x1, y1): @@ -82,11 +87,6 @@ class Rect: self.x, self.y, self.x + self.width, self.y + self.height) return s - __str__ = getquoted - - def prepare(self, conn): - pass - def show(self): """Format a description of the box.""" s = "X: %d\tY: %d\tWidth: %d\tHeight: %d" % ( |