Added a feature flag for add_srs_entry support; refs #22632 and #23504.

This commit is contained in:
Tim Graham 2014-09-17 15:55:34 -04:00
parent d8ee13789b
commit 6c1a0581ab
5 changed files with 8 additions and 4 deletions

View File

@ -16,6 +16,9 @@ class BaseSpatialFeatures(object):
# Does the database contain a SpatialRefSys model to store SRID information? # Does the database contain a SpatialRefSys model to store SRID information?
has_spatialrefsys_table = True has_spatialrefsys_table = True
# Does the backend support the django.contrib.gis.utils.add_srs_entry() utility?
supports_add_srs_entry = True
# Reference implementation of 3D functions is: # Reference implementation of 3D functions is:
# http://postgis.net/docs/PostGIS_Special_Functions_Index.html#PostGIS_3D_Functions # http://postgis.net/docs/PostGIS_Special_Functions_Index.html#PostGIS_3D_Functions
supports_3d_functions = False supports_3d_functions = False

View File

@ -10,6 +10,7 @@ from django.contrib.gis.db.backends.mysql.operations import MySQLOperations
class DatabaseFeatures(BaseSpatialFeatures, MySQLDatabaseFeatures): class DatabaseFeatures(BaseSpatialFeatures, MySQLDatabaseFeatures):
has_spatialrefsys_table = False has_spatialrefsys_table = False
supports_add_srs_entry = False
supports_distances_lookups = False supports_distances_lookups = False
supports_transform = False supports_transform = False
supports_real_shape_operations = False supports_real_shape_operations = False

View File

@ -9,7 +9,7 @@ from django.contrib.gis.db.backends.oracle.operations import OracleOperations
class DatabaseFeatures(BaseSpatialFeatures, OracleDatabaseFeatures): class DatabaseFeatures(BaseSpatialFeatures, OracleDatabaseFeatures):
pass supports_add_srs_entry = False
class DatabaseWrapper(OracleDatabaseWrapper): class DatabaseWrapper(OracleDatabaseWrapper):

View File

@ -105,6 +105,7 @@ class SpatialRefSysTest(unittest.TestCase):
for i in range(3): for i in range(3):
self.assertAlmostEqual(ellps1[i], ellps2[i], prec[i]) self.assertAlmostEqual(ellps1[i], ellps2[i], prec[i])
@skipUnlessDBFeature('supports_add_srs_entry')
def test_add_entry(self): def test_add_entry(self):
""" """
Test adding a new entry in the SpatialRefSys model using the Test adding a new entry in the SpatialRefSys model using the

View File

@ -39,9 +39,8 @@ def add_srs_entry(srs, auth_name='EPSG', auth_srid=None, ref_sys_name=None,
if not hasattr(connection.ops, 'spatial_version'): if not hasattr(connection.ops, 'spatial_version'):
raise Exception('The `add_srs_entry` utility only works ' raise Exception('The `add_srs_entry` utility only works '
'with spatial backends.') 'with spatial backends.')
if connection.ops.oracle or connection.ops.mysql: if not connection.features.supports_add_srs_entry:
raise Exception('This utility does not support the ' raise Exception('This utility does not support your database backend.')
'Oracle or MySQL spatial backends.')
SpatialRefSys = connection.ops.spatial_ref_sys() SpatialRefSys = connection.ops.spatial_ref_sys()
# If argument is not a `SpatialReference` instance, use it as parameter # If argument is not a `SpatialReference` instance, use it as parameter