[py3] Updated PostGIS adapter

This commit is contained in:
Claude Paroz 2012-09-23 20:32:17 +02:00
parent 799786a7b6
commit 874908e3bb
1 changed files with 3 additions and 2 deletions

View File

@ -1,6 +1,7 @@
""" """
This object provides quoting for GEOS geometries into PostgreSQL/PostGIS. This object provides quoting for GEOS geometries into PostgreSQL/PostGIS.
""" """
from __future__ import unicode_literals
from psycopg2 import Binary from psycopg2 import Binary
from psycopg2.extensions import ISQLQuote from psycopg2.extensions import ISQLQuote
@ -10,7 +11,7 @@ class PostGISAdapter(object):
"Initializes on the geometry." "Initializes on the geometry."
# Getting the WKB (in string form, to allow easy pickling of # Getting the WKB (in string form, to allow easy pickling of
# the adaptor) and the SRID from the geometry. # the adaptor) and the SRID from the geometry.
self.ewkb = str(geom.ewkb) self.ewkb = bytes(geom.ewkb)
self.srid = geom.srid self.srid = geom.srid
self._adapter = Binary(self.ewkb) self._adapter = Binary(self.ewkb)
@ -39,7 +40,7 @@ class PostGISAdapter(object):
def getquoted(self): def getquoted(self):
"Returns a properly quoted string for use in PostgreSQL/PostGIS." "Returns a properly quoted string for use in PostgreSQL/PostGIS."
# psycopg will figure out whether to use E'\\000' or '\000' # psycopg will figure out whether to use E'\\000' or '\000'
return 'ST_GeomFromEWKB(%s)' % self._adapter.getquoted() return str('ST_GeomFromEWKB(%s)' % self._adapter.getquoted().decode())
def prepare_database_save(self, unused): def prepare_database_save(self, unused):
return self return self