Author: jbronn
Date: 2008-09-09 14:19:51 -0500 (Tue, 09 Sep 2008)
New Revision: 8994
Modified:
django/trunk/django/contrib/gis/db/backend/oracle/models.py
django/trunk/django/contrib/gis/db/backend/postgis/models.py
django/trunk/django/contrib/gis/utils/layermapping.py
Log:
Fixed #8881 by specifying the geometry column name; added the `geom_col_name`
classmethod to `GeometryColumns` for Oracle and PostGIS.
Modified: django/trunk/django/contrib/gis/db/backend/oracle/models.py
===================================================================
--- django/trunk/django/contrib/gis/db/backend/oracle/models.py 2008-09-09
19:09:05 UTC (rev 8993)
+++ django/trunk/django/contrib/gis/db/backend/oracle/models.py 2008-09-09
19:19:51 UTC (rev 8994)
@@ -21,8 +21,20 @@
@classmethod
def table_name_col(cls):
+ """
+ Returns the name of the metadata column used to store the
+ the feature table name.
+ """
return 'table_name'
+ @classmethod
+ def geom_col_name(cls):
+ """
+ Returns the name of the metadata column used to store the
+ the feature geometry column.
+ """
+ return 'column_name'
+
def __unicode__(self):
return '%s - %s (SRID: %s)' % (self.table_name, self.column_name,
self.srid)
Modified: django/trunk/django/contrib/gis/db/backend/postgis/models.py
===================================================================
--- django/trunk/django/contrib/gis/db/backend/postgis/models.py
2008-09-09 19:09:05 UTC (rev 8993)
+++ django/trunk/django/contrib/gis/db/backend/postgis/models.py
2008-09-09 19:19:51 UTC (rev 8994)
@@ -27,9 +27,20 @@
@classmethod
def table_name_col(cls):
- "Class method for returning the table name column for this model."
+ """
+ Returns the name of the metadata column used to store the
+ the feature table name.
+ """
return 'f_table_name'
+ @classmethod
+ def geom_col_name(cls):
+ """
+ Returns the name of the metadata column used to store the
+ the feature geometry column.
+ """
+ return 'f_geometry_column'
+
def __unicode__(self):
return "%s.%s - %dD %s field (SRID: %d)" % \
(self.f_table_name, self.f_geometry_column,
Modified: django/trunk/django/contrib/gis/utils/layermapping.py
===================================================================
--- django/trunk/django/contrib/gis/utils/layermapping.py 2008-09-09
19:09:05 UTC (rev 8993)
+++ django/trunk/django/contrib/gis/utils/layermapping.py 2008-09-09
19:19:51 UTC (rev 8994)
@@ -179,13 +179,16 @@
self.ds = data
self.layer = self.ds[layer]
- # Setting the mapping
+ # Setting the mapping & model attributes.
self.mapping = mapping
+ self.model = model
+
+ # Checking the layer -- intitialization of the object will fail if
+ # things don't check out before hand.
+ self.check_layer()
- # Setting the model, and getting the geometry column associated
- # with the model (an exception will be raised if there is no
- # geometry column).
- self.model = model
+ # Getting the geometry column associated with the model (an
+ # exception will be raised if there is no geometry column).
self.geo_col = self.geometry_column()
# Checking the source spatial reference system, and getting
@@ -197,10 +200,6 @@
else:
self.transform = transform
- # Checking the layer -- intitialization of the object will fail if
- # things don't check out before hand.
- self.check_layer()
-
# Setting the encoding for OFTString fields, if specified.
if encoding:
# Making sure the encoding exists, if not a LookupError
@@ -246,7 +245,8 @@
there is no need to increment through each feature in the Layer.
"""
# The geometry field of the model is set here.
- # TODO: Support more than one geometry field / model.
+ # TODO: Support more than one geometry field / model. However, this
+ # depends on the GDAL Driver in use.
self.geom_field = False
self.fields = {}
@@ -512,8 +512,14 @@
# Getting the GeometryColumn object.
try:
db_table = self.model._meta.db_table
- if SpatialBackend.name == 'oracle': db_table = db_table.upper()
- gc_kwargs = {GeometryColumns.table_name_col() : db_table}
+ geo_col = self.geom_field
+ if SpatialBackend.name == 'oracle':
+ # Making upper case for Oracle.
+ db_table = db_table.upper()
+ geo_col = geo_col.upper()
+ gc_kwargs = {GeometryColumns.table_name_col() : db_table,
+ GeometryColumns.geom_col_name() : geo_col,
+ }
return GeometryColumns.objects.get(**gc_kwargs)
except Exception, msg:
raise LayerMapError('Geometry column does not exist for model.
(did you run syncdb?):\n %s' % msg)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---