  from django.contrib.gis.gdal import HAS_GDAL
  if HAS_GDAL:
      from django.contrib.gis.utils.ogrinfo import ogrinfo, sample
      from django.contrib.gis.utils.ogrinspect import mapping, ogrinspect
      from django.contrib.gis.utils.srs import add_postgis_srs
      try:
          # LayerMapping requires DJANGO_SETTINGS_MODULE to be set, 
          # so this needs to be in try/except.
          from django.contrib.gis.utils.layermapping import LayerMapping, LayerMapError
      except:
 
</s> remove      ref_sys_name: For SpatiaLite users only, sets the value of the
                   the `ref_sys_name` field.  Defaults to the name
                   determined by GDAL.
    """
    from django.contrib.gis.db.backend import SpatialBackend
    from django.contrib.gis.models import SpatialRefSys
    from django.contrib.gis.gdal import SpatialReference
 </s> add      ref_sys_name:
       For SpatiaLite users only, sets the value of the the `ref_sys_name` field.
       Defaults to the name determined by GDAL. </s> remove     if SpatialBackend.oracle or SpatialBackend.mysql:
        raise Exception('This utility not supported on Oracle or MySQL spatial backends.')
 </s> add      database:
      The name of the database connection to use; the default is the value
      of `django.db.DEFAULT_DB_ALIAS` (at the time of this writing, it's value
      is 'default').
    """
    connection = connections[database]
    if not hasattr(connection.ops, 'spatial_version'):
        raise Exception('The `add_srs_entry` utility only works '
                        'with spatial backends.')
    if connection.ops.oracle or connection.ops.mysql:
        raise Exception('This utility does not support the '
                        'Oracle or MySQL spatial backends.')
    SpatialRefSys = connection.ops.spatial_ref_sys() </s> remove     sr, created = SpatialRefSys.objects.get_or_create(**kwargs)
 </s> add     try:
        # Try getting via SRID only, because using all kwargs may
        # differ from exact wkt/proj in database.
        sr = SpatialRefSys.objects.get(srid=srs.srid)
    except SpatialRefSys.DoesNotExist:
        sr = SpatialRefSys.objects.create(**kwargs)

# Alias is for backwards-compatibility purposes.
add_postgis_srs = add_srs_entry </s> remove def add_postgis_srs(srs, auth_name='EPSG', auth_srid=None, ref_sys_name=None):
 </s> add from django.contrib.gis.gdal import SpatialReference
from django.db import connections, DEFAULT_DB_ALIAS

def add_srs_entry(srs, auth_name='EPSG', auth_srid=None, ref_sys_name=None,
                  database=DEFAULT_DB_ALIAS): </s> remove     >>> add_postgis_srs(SpatialReference(900913))
 </s> add     >>> from django.contrib.gis.utils import add_srs_entry
    >>> add_srs_entry(900913)
    from django.contrib.gis.utils.srs import add_postgis_srs, add_srs_entry
  from django.contrib.gis.gdal import HAS_GDAL
  if HAS_GDAL:
      from django.contrib.gis.utils.ogrinfo import ogrinfo, sample
      from django.contrib.gis.utils.ogrinspect import mapping, ogrinspect
    from django.contrib.gis.utils.srs import add_postgis_srs, add_srs_entry
      try:
          # LayerMapping requires DJANGO_SETTINGS_MODULE to be set, 
          # so this needs to be in try/except.
          from django.contrib.gis.utils.layermapping import LayerMapping, LayerMapError
      except:
keep keep keep keep replace keep keep keep keep keep
 Fixed #12591 -- Renamed `add_postgis_srs` to `add_srs_entry` (keeping backwards-compatible alias), added `database` keyword for multi-db, removed deprecated `SpatialBackend` references; no longer use `get_or_create` and look for existing entry based on SRID value. 


git-svn-id: http://code.djangoproject.com/svn/django/trunk@12228 bcc190cf-cafb-0310-a4f2-bffc1f526a37 
django/contrib/gis/utils/__init__.py