Code

Ticket #11677: postgis-fedora.diff

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

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

Line 
1Index: django/contrib/gis/db/backend/postgis/creation.py
2===================================================================
3--- django/contrib/gis/db/backend/postgis/creation.py   (revision 11428)
4+++ django/contrib/gis/db/backend/postgis/creation.py   (working copy)
5@@ -190,12 +190,25 @@
6             sql_path = '/usr/local/share'
7 
8     # The PostGIS SQL post-creation files.
9-    lwpostgis_file = os.path.join(sql_path, 'lwpostgis.sql')
10-    srefsys_file = os.path.join(sql_path, 'spatial_ref_sys.sql')
11-    if not os.path.isfile(lwpostgis_file):
12-        raise Exception('Could not find PostGIS function definitions in %s' % lwpostgis_file)
13-    if not os.path.isfile(srefsys_file):
14-        raise Exception('Could not find PostGIS spatial reference system definitions in %s' % srefsys_file)
15+    lwpostgis_file_locations = (
16+        os.path.join(sql_path, 'lwpostgis.sql'),
17+        os.path.join(sql_path, 'contrib', 'lwpostgis.sql'),
18+        os.path.join(sql_path, 'contrib', 'lwpostgis-64.sql'),
19+    )
20+    srefsys_file_locations = (
21+        os.path.join(sql_path, 'spatial_ref_sys.sql'),
22+        os.path.join(sql_path, 'contrib', 'spatial_ref_sys.sql'),
23+    )
24+    for lwpostgis_file in lwpostgis_file_locations:
25+        if os.path.isfile(lwpostgis_file):
26+            break
27+    else:
28+        raise Exception('Could not find PostGIS function definitions in any of %s' % lwpostgis_file_locations)
29+    for srefsys_file in srefsys_file_locations:
30+        if os.path.isfile(srefsys_file):
31+            break
32+    else:
33+        raise Exception('Could not find PostGIS spatial reference system definitions in any of %s' % srefsys_file_locations)
34 
35     # Getting the psql command-line options, and command format.
36     options = get_cmd_options(db_name)
37