django-pybrowscap

A Django middleware with support for pybrowscap
Download

django-pybrowscap Ranking & Summary

Advertisement

  • Rating:
  • License:
  • BSD License
  • Price:
  • FREE
  • Publisher Name:
  • VladimĂ­r Gorej
  • Publisher web site:
  • http://www.codescale.net/

django-pybrowscap Tags


django-pybrowscap Description

django-pybrowscap is a Django middleware with support for pybrowscap. It decorates request with browser attribute, browser being instance of pybrowscap.Browser class.InstallationInstall via pipy or copy this module into your project or into your PYTHON_PATH. Download latest version of browscap.csv file from http://browsers.garykeith.com/downloads.asp.Put django_pybrowscap into INSTALLED_APPS in your projects settings.py fileINSTALLED_APPS = ( 'localeurl', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.admin', 'django.contrib.sitemaps', 'web', 'debug_toolbar', 'rosetta', 'south', 'django_pybrowscap')Put django_pybrowscap.middleware.PybrowscapMiddleware into MIDDLEWARE_CLASSES in your projects settings.py fileMIDDLEWARE_CLASSES = ( 'web.middleware.LocaleMiddleware', 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django_pybrowscap.middleware.PybrowscapMiddleware', ....)Configurationdjango settings.py constants# This setting will effectively turn the middleware off, to speed up requests/response while developingPYBROWSCAP_INITIALIZE = True # Default is `not settings.DEBUG`.# Path where browscap file is located on filesystemPYBROWSCAP_FILE_PATH = MEDIA_ROOT+os.sep+'browscap.csv' # Default is '' (empty string)# Whether to perform automatic updates of browscap filePYBROWSCAP_UPDATE = False # Default is False# Interval of automatic browscap file updatesPYBROWSCAP_UPDATE_INTERVAL = 604800 # Default one week in seconds# Tuple or regex expressions of path that are to be ignored by middlewarePYBROWSCAP_IGNORE_PATHS = ( re.compile(r'^/sitemap.xml$'), re.compile(r'^/robots.txt$'), re.compile(r'^/favicon.ico$'), re.compile(r'^/media/')) # Default empty tuppledjango-pybrowscap is a Django middleware with support for pybrowscap.def standard_view(request): if request.browser is not None and request.browser.is_crawler(): # do something else: # do something elseProduct's homepage


django-pybrowscap Related Software