Changeset 8012 for django/branches/gis/django/contrib/gis/utils
- Timestamp:
- 07/20/08 16:30:46 (4 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/gis/django/contrib/gis/utils/geoip.py
r6918 r8012 41 41 import os, re 42 42 from ctypes import c_char_p, c_float, c_int, Structure, CDLL, POINTER 43 from ctypes.util import find_library 43 44 from django.conf import settings 44 45 if not settings._target: settings.configure() … … 48 49 for key in ('GEOIP_PATH', 'GEOIP_LIBRARY_PATH', 'GEOIP_COUNTRY', 'GEOIP_CITY') 49 50 if hasattr(settings, key)) 50 lib_ name= GEOIP_SETTINGS.get('GEOIP_LIBRARY_PATH', None)51 lib_path = GEOIP_SETTINGS.get('GEOIP_LIBRARY_PATH', None) 51 52 52 53 # GeoIP Exception class. … … 55 56 # The shared library for the GeoIP C API. May be downloaded 56 57 # from http://www.maxmind.com/download/geoip/api/c/ 57 if lib_name: 58 pass 59 elif os.name == 'nt': 60 lib_name = 'libGeoIP.dll' 61 elif os.name == 'posix': 62 platform = os.uname()[0] 63 if platform == 'Darwin': 64 lib_name = 'libGeoIP.dylib' 65 else: 66 lib_name = 'libGeoIP.so' 58 if lib_path: 59 lib_name = None 67 60 else: 68 raise GeoIPException('Unknown POSIX platform "%s"' % platform) 69 lgeoip = CDLL(lib_name) 61 # TODO: Is this really the library name for Windows? 62 lib_name = 'GeoIP' 63 64 # Getting the path to the GeoIP library. 65 if lib_name: lib_path = find_library(lib_name) 66 if lib_path is None: raise GeoIPException('Could not find the GeoIP library (tried "%s"). ' 67 'Try setting GEOIP_LIBRARY_PATH in your settings.' % lib_name) 68 lgeoip = CDLL(lib_path) 70 69 71 70 # Regular expressions for recognizing IP addresses and the GeoIP
