Skip to main content

Pika plugin module for Bottle microframework

Project description

Bottle-Pika is a plugin that integrates Pika (AMQP) with your Bottle application. It automatically connects to AMQP at the beginning of a request, passes the channel to the route callback and closes the connection and channel afterwards.

To automatically detect routes that need a channel, the plugin searches for route callbacks that require a mq keyword argument (configurable) and skips routes that do not. This removes any overhead for routes that don’t need a message queue.

This plugin was originally based on the bottle-mysql plugin found at:
https://pypi.python.org/pypi/bottle-mysql

Usage Example:

import bottle
import bottle_pika
import pika

app = bottle.Bottle()
pika_plugin = bottle_pika.Plugin(pika.URLParameters('amqp://localhost/'))
app.install(pika_plugin)

@app.route('/hello')
def hello(mq):
    mq.basic_publish(...)
    return HTTPResponse(status=200)
See pika documentation on channels for more information:
http://pika.readthedocs.org/en/latest/modules/channel.html#pika.channel.Channel

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for bottle_pika, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size bottle_pika-0.1.0-py2.7.egg (5.0 kB) File type Egg Python version 2.7 Upload date Hashes View
Filename, size bottle_pika-0.1.0.tar.gz (2.7 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page