Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

Session flash messages for aiohttp.web

Project Description

aiohttp_session_flash

The library provides flash messages for aiohttp.web on top of aiohttp_session.

“Flash messages” are simply a queue of string messages (or other JSON-serializable objects) stored in the session.

Installation

pip install aiohttp_session_flash

Usage

Add session_middleware and aiohttp_session_flash.middleware to the list of app’s middleware:

app = web.Application(
        middlewares=[
                aiohttp_session.session_middleware(EncryptedCookieStorage(b'x'*32)),
                aiohttp_session_flash.middleware,
        ]
)

Within the handler, pull and push flash messages as needed:

from aiohttp import web

from aiohttp_session_flash import flash, pop_flash


async def foo(request):
        flash(request, "Hello")
        flash(request, ["This", "works", "too"])
        return web.Response(body=b'Flashed some messages')

async def bar(request):
        for message in pop_flash(request):
                print(message)
        return web.Response(body=b'OK')

Template context processor

The template context processor is provided for template libraries that can use it:

aiohttp_mako_context_processors.setup(app, [
        ...
        aiohttp_session_flash.context_processor,
])
<ul>
% for message in get_flashed_messages():
        <li>${message}</li>
% endfor
</ul>

Contributing

Running tests

pip install -r requirements_test.txt
pytest
Release History

Release History

This version
History Node

0.0.4

History Node

0.0.3

History Node

0.0.2

History Node

0.0.1

Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
aiohttp_session_flash-0.0.4.tar.gz (2.2 kB) Copy SHA256 Checksum SHA256 Source Jul 12, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting