Ticket #11677: postgis-fedora.diff

File postgis-fedora.diff, 1.7 KB (added by alexdutton, 6 years ago)

SVN diff of changes to check more than one location for postgis files.

  • django/contrib/gis/db/backend/postgis/creation.py

     
    190190            sql_path = '/usr/local/share'
    191191
    192192    # The PostGIS SQL post-creation files.
    193     lwpostgis_file = os.path.join(sql_path, 'lwpostgis.sql')
    194     srefsys_file = os.path.join(sql_path, 'spatial_ref_sys.sql')
    195     if not os.path.isfile(lwpostgis_file):
    196         raise Exception('Could not find PostGIS function definitions in %s' % lwpostgis_file)
    197     if not os.path.isfile(srefsys_file):
    198         raise Exception('Could not find PostGIS spatial reference system definitions in %s' % srefsys_file)
     193    lwpostgis_file_locations = (
     194        os.path.join(sql_path, 'lwpostgis.sql'),
     195        os.path.join(sql_path, 'contrib', 'lwpostgis.sql'),
     196        os.path.join(sql_path, 'contrib', 'lwpostgis-64.sql'),
     197    )
     198    srefsys_file_locations = (
     199        os.path.join(sql_path, 'spatial_ref_sys.sql'),
     200        os.path.join(sql_path, 'contrib', 'spatial_ref_sys.sql'),
     201    )
     202    for lwpostgis_file in lwpostgis_file_locations:
     203        if os.path.isfile(lwpostgis_file):
     204            break
     205    else:
     206        raise Exception('Could not find PostGIS function definitions in any of %s' % lwpostgis_file_locations)
     207    for srefsys_file in srefsys_file_locations:
     208        if os.path.isfile(srefsys_file):
     209            break
     210    else:
     211        raise Exception('Could not find PostGIS spatial reference system definitions in any of %s' % srefsys_file_locations)
    199212
    200213    # Getting the psql command-line options, and command format.
    201214    options = get_cmd_options(db_name)
Back to Top