HTTP User-Agent parser for Pyramid
Project description
Project Info
Provides an HTTP User-Agent parser 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 parsed(request):
ua = request.user_agent_parsed # I'am reified!
name_of_first_component = ua.maincomponent.name
version_of_first_component = ua.maincomponent.version
comments_of_first_component = ua.maincomponent.comments
name_of_third_component = ua.components.values()[2].name
if request.user_agent_parsed.maincomponent.name == 'Links':
return "Did you really use Links?"
else:
return ua.components.values()
Tests and Docs
pip install -e .[testing]
nosetests
pip install -e .[docs]
cd docs
make html
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
pyramid_useragent-0.1.tar.gz
(13.1 kB
view hashes)
Built Distribution
Close
Hashes for pyramid_useragent-0.1-py27-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4ff462dddd5174c524ed9feb4dbd03ee5c30c1e2516540ae61da26d0dd20b00c |
|
MD5 | 11b8431c8b73b0e5ba41bbd35b1055b3 |
|
BLAKE2b-256 | 4d7276e7ffc20fee54b0bdd36a92f3e60be6bd4d69cdc27e0671eabd1614bf64 |