Hello I created my own type, Geometry, to deal with PostGIS' geometry column type.
---- class Geometry(TypeEngine): def __init__(self, srid=-1, dims=2): super(Geometry, self).__init__() self.srid = srid self.dims = dims def get_col_spec(self): return 'GEOMETRY()' def compare_values(self, x, y): return x.equals(y) def convert_bind_param(self, value, engine): """convert value from a geometry object to database""" if value is None: return None else: return "SRID=%s;%s" % (self.srid, value.wkb.encode('hex')) def convert_result_value(self, value, engine): """convert value from database to a geometry object""" if value is None: return None else: return loads(value.decode('hex')) ---- So far, so good; user can do: wifi_table = Table('wifi', metadata, Column('the_geom', Geometry(4326)), autoload=True) But ultimately I'd like that my users can do: wifi_table = Table('wifi', metadata, autoload=True) I tried this: from sqlalchemy.databases import postgres postgres.ischema_names['geometry'] = Geometry This is ok, but during reflection, when SQLA creates Geometry objects, it obviously passes no "srid" argument to the Geometry constructor, so the Geometry objects all end up with the "srid" property set to -1. The proper "srid" value to pass to the Geometry constructor is actually in a PostGIS table (geometry_columns). So if a geometry column is discovered, the table's "srid" value could be read from that table and passed to the Geometry constructor. I thought about doing something like that: from sqlalchemy.databases import postgres def geometry_factory(): // go read srid associated with table from geometry_columns srid = return Geometry(srid) postgres.ischema_names['geometry'] = geometry_factory but geometry_factory doesn't have any connection object to go read the srid value. My question is simple: do you see solutions to my problem? Thanks, -- Eric --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---