Skip to main content

Dogpile support for cherrypy.

Project description

dogpile support for cherrypy.

Installation

pip install marbaloo_dogpile

Usage

# app.py
import cherrypy
import marbaloo_dogpile
import os

marbaloo_dogpile.Plugin(cherrypy.engine).subscribe()
cherrypy.tools.dogpile = marbaloo_dogpile.Tool()


class Root(object):

    @cherrypy.expose
    def index(self):
        dogpile = cherrypy.request.dogpile
        counter = dogpile.get('counter')
        counter = 0 if isinstance(counter, int) is False else counter
        dogpile.set('counter', counter + 1)
        return str(counter)

root_path = os.path.dirname(__file__)
dogpile_dbm_path = os.path.join(root_path, 'dogpile.dbm')
config = {
    'global': {
        'marbaloo_dogpile': {
            'backend': 'dogpile.cache.dbm',
            'expiration_time': 3600,
            'arguments': {'filename': dogpile_dbm_path},
        }
    },
    '/': {
        'tools.dogpile.on': True
    }
}
cherrypy.quickstart(Root(), '/', config)

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

marbaloo_dogpile-0.1.0.tar.gz (2.5 kB view details)

Uploaded Source

File details

Details for the file marbaloo_dogpile-0.1.0.tar.gz.

File metadata

File hashes

Hashes for marbaloo_dogpile-0.1.0.tar.gz
Algorithm Hash digest
SHA256 10e39065a1c37be0bf7f0cb146888557e68a62cef499f2aed7e264651384d512
MD5 cea9e19238f66d11a4dbf7201feaa372
BLAKE2b-256 114dfbc1c66189795182b965e84e72281b9670cf5fdb12ccc01ad225dfb56f81

See more details on using hashes here.

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