Lines 12-17
Link Here
|
12 |
# the adaptor) and the SRID from the geometry. |
12 |
# the adaptor) and the SRID from the geometry. |
13 |
self.ewkb = str(geom.ewkb) |
13 |
self.ewkb = str(geom.ewkb) |
14 |
self.srid = geom.srid |
14 |
self.srid = geom.srid |
|
|
15 |
self._adapter = Binary(self.ewkb) |
15 |
|
16 |
|
16 |
def __conform__(self, proto): |
17 |
def __conform__(self, proto): |
17 |
# Does the given protocol conform to what Psycopg2 expects? |
18 |
# Does the given protocol conform to what Psycopg2 expects? |
Lines 26-35
Link Here
|
26 |
def __str__(self): |
27 |
def __str__(self): |
27 |
return self.getquoted() |
28 |
return self.getquoted() |
28 |
|
29 |
|
|
|
30 |
def prepare(self, conn): |
31 |
# Pass the connection to the adapter: this allows escaping the binary |
32 |
# in the style required by the server's standard_conforming_string setting. |
33 |
self._adapter.prepare(conn) |
34 |
|
29 |
def getquoted(self): |
35 |
def getquoted(self): |
30 |
"Returns a properly quoted string for use in PostgreSQL/PostGIS." |
36 |
"Returns a properly quoted string for use in PostgreSQL/PostGIS." |
31 |
# Want to use WKB, so wrap with psycopg2 Binary() to quote properly. |
37 |
# psycopg will figure out whether to use E'\\000' or '\000' |
32 |
return 'ST_GeomFromEWKB(E%s)' % Binary(self.ewkb) |
38 |
return 'ST_GeomFromEWKB(%s)' % self._adapter.getquoted() |
33 |
|
39 |
|
34 |
def prepare_database_save(self, unused): |
40 |
def prepare_database_save(self, unused): |
35 |
return self |
41 |
return self |