Skip to main content

HTTP User-Agent parser for Pyramid

Project description

Project Info

Provides an HTTP User-Agent parser for the Pyramid web framework.

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)

Uploaded Source

Built Distribution

pyramid_useragent-0.1-py27-none-any.whl (14.1 kB view hashes)

Uploaded Python 2.7

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page