{ "info": { "author": "Ilya Semenov", "author_email": "ilya@semenov.co", "bugtrack_url": null, "classifiers": [], "description": "aiohttp_session_flash\n=====================\n\nThe library provides flash messages for `aiohttp.web`_ on top of `aiohttp_session`_.\n\n.. _aiohttp.web: https://aiohttp.readthedocs.io/en/latest/web.html\n.. _aiohttp_session: https://github.com/aio-libs/aiohttp_session\n\n\u201cFlash messages\u201d are simply a queue of string messages (or other JSON-serializable objects) stored in the session.\n\n\nInstallation\n============\n\n::\n\n\tpip install aiohttp_session_flash\n\n\nUsage\n=====\n\nAdd `session_middleware` and `aiohttp_session_flash.middleware` to the list of `app`'s middleware:\n\n.. code:: python\n\n\tapp = web.Application(\n\t\tmiddlewares=[\n\t\t\taiohttp_session.session_middleware(EncryptedCookieStorage(b'x'*32)),\n\t\t\taiohttp_session_flash.middleware,\n\t\t]\n\t)\n\nWithin the handler, pull and push flash messages as needed:\n\n.. code:: python\n\n\tfrom aiohttp import web\n\n\tfrom aiohttp_session_flash import flash, pop_flash\n\n\n\tasync def foo(request):\n\t\tflash(request, \"Hello\")\n\t\tflash(request, [\"This\", \"works\", \"too\"])\n\t\treturn web.Response(body=b'Flashed some messages')\n\n\tasync def bar(request):\n\t\tfor message in pop_flash(request):\n\t\t\tprint(message)\n\t\treturn web.Response(body=b'OK')\n\n\nTemplate context processor\n--------------------------\n\nThe template context processor is provided for template libraries that can use it:\n\n.. code:: python\n\n\taiohttp_mako_context_processors.setup(app, [\n\t\t...\n\t\taiohttp_session_flash.context_processor,\n\t])\n\n.. code:: mako\n\n\t