HTTP User-Agent parser for Pyramid
Project description
Project Info
Provides an HTTP User-Agent parser and classifier for the Pyramid web framework.
Documentation: http://pyramid-useragent.readthedocs.org/
Bitbucket: https://bitbucket.org/pior/pyramid_useragent
Setup
Once pyramid_useragent is installed, you typically use the config.include mechanism to include it into your Pyramid project’s configuration. In your Pyramid project’s __init__.py:
config = Configurator(.....)
config.include('pyramid_useragent')
Alternately, instead of using the Configurator’s include method, you can activate Pyramid by changing your application’s .ini file, use the following line:
pyramid.includes = pyramid_useragent
Usage
def demo(request):
client = request.user_agent_classified
if client.is_mobile or client.is_tablet:
return "Download our mobile app!"
if client.is_bot:
return "Are you human? I'am human."
ua = request.user_agent_parsed
if ua.maincomponent.name == 'Links':
return "Did you REALLY use Links?"
if 'AdobeAIR' in ua.components:
if ua.components['AdobeAIR'].version == '3.9.0.1210':
return "Much unsecure, so flaws"
if ua.maincomponent.name == "Mozilla":
return "This is supposed to describe your platform: %s" % (
'; '.join(ua.maincomponent.comments))
return [c.name for c in ua.components.values()]
Tests
pip install -e .[testing]
nosetests
Documentation
pip install -e .[docs]
cd docs
make html
Changes
0.3
Add a User-Agent classifier using the user-agents project
0.2
Continuous testing
Documentation
0.1
Initial release.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pyramid_useragent-0.3.tar.gz
.
File metadata
- Download URL: pyramid_useragent-0.3.tar.gz
- Upload date:
- Size: 14.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fa8b86df665d1de8f73f0f0e53ff7bd578d1d6a960161a7fb5829ecda7f66734 |
|
MD5 | 9d4c99c15a1e623465edcba85127019f |
|
BLAKE2b-256 | 8d8e8184bb1a9c0d3a3e1ac48b0e54d66859c22523d87feffc5c882cf6d94e9a |
Provenance
File details
Details for the file pyramid_useragent-0.3-py27-none-any.whl
.
File metadata
- Download URL: pyramid_useragent-0.3-py27-none-any.whl
- Upload date:
- Size: 16.0 kB
- Tags: Python 2.7
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b881f16fa8ca444842a1d00bd5214dc59681474265df8c07f2a79babd8d32120 |
|
MD5 | 978ae1f7c32e62a2bad1a05bbdd7a830 |
|
BLAKE2b-256 | 84957091f26adc3bd35d5f14c2bd72e15d75670cc1c56312c0773cb33a9b14dd |