Django

Code

Show
Ignore:
Timestamp:
07/30/08 12:46:02 (4 months ago)
Author:
jbronn
Message:

gis: Now plays nice with the Django test suite if the spatial prerequisites aren't installed.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/gis/django/contrib/gis/models.py

    r7666 r8155  
    212212_srid_info = True 
    213213if settings.DATABASE_ENGINE == 'postgresql_psycopg2': 
    214     from django.contrib.gis.db.backend.postgis.models import GeometryColumns, SpatialRefSys 
     214    # Because the PostGIS version is checked when initializing the spatial  
     215    # backend a `ProgrammingError` will be raised if the PostGIS tables  
     216    # and functions are not installed.  We catch here so it won't be raised when  
     217    # running the Django test suite. 
     218    from psycopg2 import ProgrammingError 
     219    try: 
     220        from django.contrib.gis.db.backend.postgis.models import GeometryColumns, SpatialRefSys 
     221    except ProgrammingError: 
     222        _srid_info = False 
    215223elif settings.DATABASE_ENGINE == 'oracle': 
    216     from django.contrib.gis.db.backend.oracle.models import GeometryColumns, SpatialRefSys 
     224    # Same thing as above, except the GEOS library is attempted to be loaded for 
     225    # `BaseSpatialBackend`, and an exception will be raised during the 
     226    # Django test suite if it doesn't exist. 
     227    try: 
     228        from django.contrib.gis.db.backend.oracle.models import GeometryColumns, SpatialRefSys 
     229    except: 
     230        _srid_info = False 
    217231else: 
    218232    _srid_info = False