Django

Code

Changeset 6527

Show
Ignore:
Timestamp:
10/18/07 19:34:29 (1 year ago)
Author:
jbronn
Message:

gis: Added preliminary spatial backend for MySQL (which only supports MBR queries), and added limited test suite for it; updated a few comments in the Oracle backend.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/gis/django/contrib/gis/db/backend/__init__.py

    r6524 r6527  
    4444         ASGML, GEOM_SELECT, TRANSFORM, UNION 
    4545    SPATIAL_BACKEND = 'oracle' 
     46elif settings.DATABASE_ENGINE == 'mysql': 
     47    from django.contrib.gis.db.backend.mysql import \ 
     48        MySQLGeoField as GeoBackendField, \ 
     49        MYSQL_GIS_TERMS as GIS_TERMS, \ 
     50        create_spatial_db, get_geo_where_clause, gqn, \ 
     51        GEOM_SELECT 
     52    SPATIAL_BACKEND = 'mysql' 
    4653else: 
    4754    raise NotImplementedError('No Geographic Backend exists for %s' % settings.DATABASE_ENGINE) 
  • django/branches/gis/django/contrib/gis/db/backend/oracle/__init__.py

    r6524 r6527  
    22 The Oracle spatial database backend module. 
    33 
    4  Please note that WKT support is broken on the XE version, and this will 
    5  not work. 
     4 Please note that WKT support is broken on the XE version, and thus 
     5 this backend will not work on such platforms.  Specifically, XE lacks  
     6 support for an internal JVM, and Java libraries are required to use  
     7 the WKT constructors. 
    68""" 
    79from django.contrib.gis.db.backend.oracle.creation import create_spatial_db 
  • django/branches/gis/django/contrib/gis/db/backend/oracle/query.py

    r6524 r6527  
    3636    field_name = qn(field_name) 
    3737 
    38     # See if a PostGIS Geometry function matches the lookup type next 
     38    # See if a Oracle Geometry function matches the lookup type next 
    3939    lookup_info = ORACLE_GEOMETRY_FUNCTIONS.get(lookup_type, False) 
    4040    if lookup_info: 
  • django/branches/gis/django/contrib/gis/tests/geoapp/models.py

    r6467 r6527  
    11from django.contrib.gis.db import models 
     2from django.contrib.gis.tests.utils import mysql 
     3 
     4# MySQL spatial indices can't handle NULL geometries. 
     5null_flag = not mysql 
    26 
    37class Country(models.Model): 
     
    1317class State(models.Model): 
    1418    name = models.CharField(max_length=30) 
    15     poly = models.PolygonField(null=True) # Allowing NULL geometries here. 
     19    poly = models.PolygonField(null=null_flag) # Allowing NULL geometries here. 
    1620    objects = models.GeoManager() 
    1721 
  • django/branches/gis/django/contrib/gis/tests/__init__.py

    r6441 r6527  
    33from unittest import TestSuite, TextTestRunner 
    44from django.contrib.gis.gdal import HAS_GDAL 
     5from django.contrib.gis.tests.utils import mysql 
    56 
    67# Tests that do not require setting up and tearing down a spatial database. 
     
    8586    for test_model in test_models: 
    8687        module_name = 'django.contrib.gis.tests.%s' % test_model 
     88        if mysql: 
     89            test_module_name = 'tests_mysql' 
     90        else: 
     91            test_module_name = 'tests' 
    8792        settings.INSTALLED_APPS.append(module_name) 
    88         tsuite = getattr(__import__('django.contrib.gis.tests.%s' % test_model, globals(), locals(), ['tests']), 'tests'
     93        tsuite = getattr(__import__('django.contrib.gis.tests.%s' % test_model, globals(), locals(), [test_module_name]), test_module_name
    8994        test_suite.addTest(tsuite.suite()) 
    9095 
  • django/branches/gis/django/contrib/gis/tests/test_spatialrefsys.py

    r6524 r6527  
    11import unittest 
    2 from django.contrib.gis.models import SpatialRefSys 
    3 from django.contrib.gis.tests.utils import oracle, postgis 
     2from django.contrib.gis.tests.utils import mysql, no_mysql, oracle, postgis 
     3if not mysql: 
     4    from django.contrib.gis.models import SpatialRefSys 
    45 
    56test_srs = ({'srid' : 4326, 
     
    2728class SpatialRefSysTest(unittest.TestCase): 
    2829 
     30    @no_mysql 
    2931    def test01_retrieve(self): 
    3032        "Testing retrieval of SpatialRefSys model objects." 
     
    4749                self.assertEqual(sd['proj4'], srs.proj4text) 
    4850 
     51    @no_mysql 
    4952    def test02_osr(self): 
    5053        "Testing getting OSR objects from SpatialRefSys model objects." 
     
    6265                self.assertEqual(sd['srtext'], srs.wkt) 
    6366 
     67    @no_mysql 
    6468    def test03_ellipsoid(self): 
    6569        "Testing the ellipsoid property." 
  • django/branches/gis/django/contrib/gis/tests/utils.py

    r6524 r6527  
    1515def no_oracle(func): return no_backend(func, 'oracle') 
    1616def no_postgis(func): return no_backend(func, 'postgresql_psycopg2') 
     17def no_mysql(func): return no_backend(func, 'mysql') 
    1718 
    1819# Shortcut booleans to omit only portions of tests. 
    1920oracle  = settings.DATABASE_ENGINE == 'oracle' 
    2021postgis = settings.DATABASE_ENGINE == 'postgresql_psycopg2'  
     22mysql   = settings.DATABASE_ENGINE == 'mysql'