Source: python-django
Version: 1.3.1-1
Severity: wishlist

GeoIP database should be accessible without further configuration after
installing package geoip-database-contrib.
A patch is attached to change the defaults.

Also python-django could have Suggests: geoip-database-contrib

>From 88c19ec756e6c82c49dfe401c0c930e18887916f Mon Sep 17 00:00:00 2001
From: Tapio Rantala <tapio.rant...@iki.fi>
Date: Wed, 12 Oct 2011 12:31:33 +0300
Subject: [PATCH] Use Debian default settings GeoIP database

---
 django/contrib/gis/utils/geoip.py |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/django/contrib/gis/utils/geoip.py b/django/contrib/gis/utils/geoip.py
index eedaef9..243dd29 100644
--- a/django/contrib/gis/utils/geoip.py
+++ b/django/contrib/gis/utils/geoip.py
@@ -164,7 +164,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. Defaults to '/usr/share/GeoIP'; overrides the
+            GEOIP_PATH settings attribute.
 
         * cache: The cache settings when opening up the GeoIP datasets,
             and may be an integer in (0, 1, 2, 4) corresponding to
@@ -177,7 +178,7 @@ class GeoIP(object):
             '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.
+            'GeoIPCity.dat'; overrides the GEOIP_CITY settings attribute.
         """
         # Checking the given cache option.
         if cache in self.cache_options:
@@ -187,8 +188,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, basestring):
             raise TypeError('Invalid path type: %s' % type(path).__name__)
 
@@ -201,7 +201,7 @@ class GeoIP(object):
                 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
-- 
1.7.2.5

Reply via email to