Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #8881 by specifying the geometry column name; added the `geom_c…

…ol_name` classmethod to `GeometryColumns` for Oracle and PostGIS.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@8994 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 152b9ba7173e74fae11c770be40656cc70188514 1 parent 2dd4b94
Justin Bronn authored September 09, 2008
12  django/contrib/gis/db/backend/oracle/models.py
@@ -21,8 +21,20 @@ class Meta:
21 21
 
22 22
     @classmethod
23 23
     def table_name_col(cls):
  24
+        """
  25
+        Returns the name of the metadata column used to store the 
  26
+        the feature table name.
  27
+        """
24 28
         return 'table_name'
25 29
 
  30
+    @classmethod
  31
+    def geom_col_name(cls):
  32
+        """
  33
+        Returns the name of the metadata column used to store the 
  34
+        the feature geometry column.
  35
+        """
  36
+        return 'column_name'
  37
+
26 38
     def __unicode__(self):
27 39
         return '%s - %s (SRID: %s)' % (self.table_name, self.column_name, self.srid)
28 40
 
13  django/contrib/gis/db/backend/postgis/models.py
@@ -27,9 +27,20 @@ class Meta:
27 27
 
28 28
     @classmethod
29 29
     def table_name_col(cls):
30  
-        "Class method for returning the table name column for this model."
  30
+        """
  31
+        Returns the name of the metadata column used to store the 
  32
+        the feature table name.
  33
+        """
31 34
         return 'f_table_name'
32 35
 
  36
+    @classmethod
  37
+    def geom_col_name(cls):
  38
+        """
  39
+        Returns the name of the metadata column used to store the 
  40
+        the feature geometry column.
  41
+        """
  42
+        return 'f_geometry_column'
  43
+
33 44
     def __unicode__(self):
34 45
         return "%s.%s - %dD %s field (SRID: %d)" % \
35 46
                (self.f_table_name, self.f_geometry_column,
30  django/contrib/gis/utils/layermapping.py
@@ -179,13 +179,16 @@ def __init__(self, model, data, mapping, layer=0,
179 179
             self.ds = data
180 180
         self.layer = self.ds[layer]
181 181
 
182  
-        # Setting the mapping
  182
+        # Setting the mapping & model attributes.
183 183
         self.mapping = mapping
184  
-
185  
-        # Setting the model, and getting the geometry column associated 
186  
-        # with the model (an exception will be raised if there is no 
187  
-        # geometry column).
188 184
         self.model = model
  185
+ 
  186
+        # Checking the layer -- intitialization of the object will fail if
  187
+        # things don't check out before hand.
  188
+        self.check_layer()
  189
+
  190
+        # Getting the geometry column associated with the model (an 
  191
+        # exception will be raised if there is no geometry column).
189 192
         self.geo_col = self.geometry_column()
190 193
 
191 194
         # Checking the source spatial reference system, and getting
@@ -197,10 +200,6 @@ def __init__(self, model, data, mapping, layer=0,
197 200
         else:
198 201
             self.transform = transform
199 202
 
200  
-        # Checking the layer -- intitialization of the object will fail if
201  
-        # things don't check out before hand.
202  
-        self.check_layer()
203  
-
204 203
         # Setting the encoding for OFTString fields, if specified.
205 204
         if encoding:
206 205
             # Making sure the encoding exists, if not a LookupError
@@ -246,7 +245,8 @@ def check_layer(self):
246 245
         there is no need to increment through each feature in the Layer.
247 246
         """
248 247
         # The geometry field of the model is set here.
249  
-        # TODO: Support more than one geometry field / model.
  248
+        # TODO: Support more than one geometry field / model.  However, this
  249
+        # depends on the GDAL Driver in use.
250 250
         self.geom_field = False
251 251
         self.fields = {}
252 252
 
@@ -512,8 +512,14 @@ def geometry_column(self):
512 512
         # Getting the GeometryColumn object.
513 513
         try:
514 514
             db_table = self.model._meta.db_table
515  
-            if SpatialBackend.name == 'oracle': db_table = db_table.upper()
516  
-            gc_kwargs = {GeometryColumns.table_name_col() : db_table}
  515
+            geo_col = self.geom_field
  516
+            if SpatialBackend.name == 'oracle':
  517
+                # Making upper case for Oracle.
  518
+                db_table = db_table.upper()
  519
+                geo_col = geo_col.upper()
  520
+            gc_kwargs = {GeometryColumns.table_name_col() : db_table,
  521
+                         GeometryColumns.geom_col_name() : geo_col,
  522
+                         }
517 523
             return GeometryColumns.objects.get(**gc_kwargs)
518 524
         except Exception, msg:
519 525
             raise LayerMapError('Geometry column does not exist for model. (did you run syncdb?):\n %s' % msg)

0 notes on commit 152b9ba

Please sign in to comment.
Something went wrong with that request. Please try again.