[Python-modules-commits] [python-django] 13/16: Use Debian GeoIP database path as default

Brian May bam at moszumanska.debian.org
Sun Oct 11 02:44:12 UTC 2015


This is an automated email from the git hooks/post-receive script.

bam pushed a commit to branch debian/sid
in repository python-django.

commit ce9711773c8b21a9c207b733e0de00401eea1748
Author: Tapio Rantala <tapio.rantala at iki.fi>
Date:   Sun Oct 11 11:34:02 2015 +1100

    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
    
    Patch-Name: 06_use_debian_geoip_database_as_default.diff
---
 django/contrib/gis/geoip/base.py | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/django/contrib/gis/geoip/base.py b/django/contrib/gis/geoip/base.py
index 9295030..0b05f43 100644
--- a/django/contrib/gis/geoip/base.py
+++ b/django/contrib/gis/geoip/base.py
@@ -67,7 +67,8 @@ class GeoIP(object):
         * 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
@@ -76,11 +77,13 @@ class GeoIP(object):
             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.
+        * 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.  Defaults to
-            'GeoLiteCity.dat'; overrides the GEOIP_CITY settings attribute.
+        * 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:
@@ -90,9 +93,7 @@ class GeoIP(object):
 
         # 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, six.string_types):
             raise TypeError('Invalid path type: %s' % type(path).__name__)
 
@@ -105,7 +106,7 @@ class GeoIP(object):
                 self._country = GeoIP_open(force_bytes(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(force_bytes(city_db), cache)
                 self._city_file = city_db

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-django.git



More information about the Python-modules-commits mailing list