1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
Description: Use Debian GeoIP database path as default
Default to Debian standard path for GeoIP directory and for GeoIP city
file. Avoids the need to declare them in each project.
.
This is a Debian specific patch.
Bug-Debian: http://bugs.debian.org/645094
Forwarded: not-needed
Author: Tapio Rantala <tapio.rantala@iki.fi>
--- a/django/contrib/gis/geoip/base.py
+++ b/django/contrib/gis/geoip/base.py
@@ -61,7 +61,8 @@
* path: Base directory to where GeoIP data is located or the full path
to where the city or country data files (*.dat) are located.
Assumes that both the city and country data sets are located in
- this directory; overrides the GEOIP_PATH settings attribute.
+ this directory. Overrides the GEOIP_PATH settings attribute.
+ If neither is set, defaults to '/usr/share/GeoIP'.
* cache: The cache settings when opening up the GeoIP datasets,
and may be an integer in (0, 1, 2, 4, 8) corresponding to
@@ -70,11 +71,13 @@
settings, respectively. Defaults to 0, meaning that the data is read
from the disk.
- * country: The name of the GeoIP country data file. Defaults to
- 'GeoIP.dat'; overrides the GEOIP_COUNTRY settings attribute.
-
- * city: The name of the GeoIP city data file. Defaults to
- 'GeoLiteCity.dat'; overrides the GEOIP_CITY settings attribute.
+ * country: The name of the GeoIP country data file. Overrides
+ the GEOIP_COUNTRY settings attribute. If neither is set,
+ defaults to 'GeoIP.dat'
+
+ * city: The name of the GeoIP city data file. Overrides the
+ GEOIP_CITY settings attribute. If neither is set, defaults
+ to 'GeoIPCity.dat'.
"""
# Checking the given cache option.
if cache in self.cache_options:
@@ -84,8 +87,7 @@
# Getting the GeoIP data path.
if not path:
- path = GEOIP_SETTINGS.get('GEOIP_PATH', None)
- if not path: raise GeoIPException('GeoIP path must be provided via parameter or the GEOIP_PATH setting.')
+ path = GEOIP_SETTINGS.get('GEOIP_PATH', '/usr/share/GeoIP')
if not isinstance(path, basestring):
raise TypeError('Invalid path type: %s' % type(path).__name__)
@@ -98,7 +100,7 @@
self._country = GeoIP_open(country_db, cache)
self._country_file = country_db
- city_db = os.path.join(path, city or GEOIP_SETTINGS.get('GEOIP_CITY', 'GeoLiteCity.dat'))
+ city_db = os.path.join(path, city or GEOIP_SETTINGS.get('GEOIP_CITY', 'GeoIPCity.dat'))
if os.path.isfile(city_db):
self._city = GeoIP_open(city_db, cache)
self._city_file = city_db
|