gis: Fixed #8207; now shield 2.4 test runners from attempting to import ctypes.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@8289 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Justin Bronn 2008-08-10 17:36:12 +00:00
parent 56f1f1fa9e
commit 5b27c36041
2 changed files with 10 additions and 7 deletions

View File

@ -47,9 +47,13 @@ except:
HAS_GDAL, GEOJSON = False, False
# The envelope, error, and geomtype modules do not actually require the
# GDAL library.
# GDAL library, but still nead at least Python 2.4 and ctypes.
PYTHON23 = sys.version_info[0] == 2 and sys.version_info[1] == 3
if not PYTHON23:
from django.contrib.gis.gdal.envelope import Envelope
from django.contrib.gis.gdal.error import check_err, OGRException, OGRIndexError, SRSException
from django.contrib.gis.gdal.geomtype import OGRGeomType
try:
from django.contrib.gis.gdal.envelope import Envelope
from django.contrib.gis.gdal.error import check_err, OGRException, OGRIndexError, SRSException
from django.contrib.gis.gdal.geomtype import OGRGeomType
except ImportError:
# No ctypes, but don't raise an exception.
pass

View File

@ -214,11 +214,10 @@ if not PYTHON23 and settings.DATABASE_ENGINE == 'postgresql_psycopg2':
# Because the PostGIS version is checked when initializing the spatial
# backend a `ProgrammingError` will be raised if the PostGIS tables
# and functions are not installed. We catch here so it won't be raised when
# running the Django test suite.
from psycopg2 import ProgrammingError
# running the Django test suite. `ImportError` is also possible if no ctypes.
try:
from django.contrib.gis.db.backend.postgis.models import GeometryColumns, SpatialRefSys
except ProgrammingError:
except:
_srid_info = False
elif not PYTHON23 and settings.DATABASE_ENGINE == 'oracle':
# Same thing as above, except the GEOS library is attempted to be loaded for