Skip to content

Commit 9b3837c

Browse files
committed
Bump to 1.2.0
1 parent e1b3e2f commit 9b3837c

File tree

5 files changed

+77
-19
lines changed

5 files changed

+77
-19
lines changed

CHANGES.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
Changes
22
=======
33

4+
5+
1.2.0 (2017-11-06)
6+
------------------
7+
8+
- Add MemcachedStorage #224
9+
410
1.1.0 (2017-11-03)
511
------------------
612

aiohttp_session/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from aiohttp import web
1010

1111

12-
__version__ = '1.1.0'
12+
__version__ = '1.2.0'
1313

1414

1515
class Session(MutableMapping):

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,6 @@
332332
intersphinx_mapping = {'https://docs.python.org/3': None,
333333
'https://aiohttp.readthedocs.io/en/stable': None,
334334
'https://aioredis.readthedocs.io/en/latest': None,
335-
'https://github.com/aio-libs/aiomcache', None,
335+
# 'https://github.com/aio-libs/aiomcache': None,
336336
'http://cryptography.io/en/latest': None,
337337
'https://pynacl.readthedocs.io/en/latest': None}

docs/index.rst

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,27 +61,41 @@ Available session storages are:
6161

6262
Requires :term:`cryptography` library::
6363

64-
$ pip install aiohttp_session[secure]
64+
.. code::
65+
66+
$ pip3 install aiohttp_session[secure]
6567
6668
* :class:`~aiohttp_session.redis_storage.RedisStorage` -- stores
6769
JSON-ed data into *redis*, keeping into cookie only redis key
6870
(random UUID).
69-
71+
7072
Inside redis the key will be saved as COOKIENAME_VALUEOFTHECOOKIE.
71-
For example if inside the browser the cookie is saved with name 'AIOHTTP_SESSION' (default option)
72-
and value e33b57c7ec6e425eb626610f811ab6ae (a random UUID) they key inside redis will be
73-
AIOHTTP_SESSION_e33b57c7ec6e425eb626610f811ab6ae.
73+
For example if inside the browser the cookie is saved with name
74+
``'AIOHTTP_SESSION'`` (default option) and value
75+
``e33b57c7ec6e425eb626610f811ab6ae`` (a random UUID) they key inside
76+
redis will be ``AIOHTTP_SESSION_e33b57c7ec6e425eb626610f811ab6ae``.
7477

75-
Requires :term:`aioredis` library::
78+
Requires :term:`aioredis` library:
79+
80+
.. code-block:: bash
7681
7782
$ pip install aiohttp_session[aioredis]
7883
84+
* :class:`~aiohttp_session.memcached_storage.MemcachedStorage` -- the
85+
same as Redis storage but uses Memcached database.
86+
87+
Requires :term:`aiomcache` library:
88+
89+
.. code-block:: bash
90+
91+
$ pip install aiohttp_session[aiomcache]
92+
7993
Installation
8094
--------------------
8195

82-
.. code::
96+
.. code-block:: bash
8397
84-
pip3 install aiohttp_session
98+
$ pip3 install aiohttp_session
8599
86100
Source code
87101
-----------

docs/reference.rst

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,7 @@ so it's totally insecure.
224224
To use the storage you should push it into
225225
:func:`session_middleware`::
226226

227-
app = aiohttp.web.Application(
228-
middlewares=[aiohttp_session.SimpleCookieStorage()])
227+
aiohttp_session.setup(app, aiohttp_session.SimpleCookieStorage())
229228

230229
.. class:: SimpleCookieStorage(*, \
231230
cookie_name="AIOHTTP_SESSION", \
@@ -325,16 +324,18 @@ It operates with Redis database via :class:`aioredis.RedisPool`.
325324

326325
To use the storage you need setup it first::
327326

328-
redis = yield from aioredis.create_pool(('localhost', 6379))
327+
redis = await aioredis.create_pool(('localhost', 6379))
329328
storage = aiohttp_session.redis_storage.RedisStorage(redis)
330-
session_middleware = aiohttp_session.session_middleware(storage)
331-
app = aiohttp.web.Application(middlewares=[session_middleware])
329+
aiohttp_session.setup(app, storage)
332330

333331

334332
.. class:: RedisStorage(redis_pool, *, \
335-
cookie_name="AIOHTTP_SESSION", \
336-
domain=None, max_age=None, path='/', \
337-
secure=None, httponly=True)
333+
cookie_name="AIOHTTP_SESSION", \
334+
domain=None, max_age=None, path='/', \
335+
secure=None, httponly=True, \
336+
encoder=json.dumps, \
337+
decoder=json.loads, \
338+
key_factory=lambda: uuid.uuid4().hex)
338339

339340
Create Redis storage for user session data.
340341

@@ -343,8 +344,45 @@ To use the storage you need setup it first::
343344
*redis_pool* is a :class:`~aioredis.RedisPool` which should be
344345
created by :func:`~aioredis.create_pool` call, e.g.::
345346

346-
redis = yield from aioredis.create_pool(('localhost', 6379))
347+
redis = await aioredis.create_pool(('localhost', 6379))
347348
storage = aiohttp_session.redis_storage.RedisStorage(redis)
348349

349350
Other parameters are the same as for
350351
:class:`~aiohttp_session.AbstractStorage` constructor.
352+
353+
354+
Memcahed Storage
355+
----------------
356+
357+
The storage that stores session data in Memcached and
358+
keeps only keys (UUIDs actually) in HTTP cookies.
359+
360+
It operates with Memcahed database via :class:`aiomecache.Client`.
361+
362+
To use the storage you need setup it first::
363+
364+
mc = aiomchache.Client('localhost', 11211)
365+
storage = aiohttp_session.memcached_storage.Client(mc)
366+
aiohttp_session.setup(app, storage)
367+
368+
.. versionadded:: 1.2
369+
370+
.. class:: MemcachedStorage(memcached_conn, *, \
371+
cookie_name="AIOHTTP_SESSION", \
372+
domain=None, max_age=None, path='/', \
373+
secure=None, httponly=True, \
374+
encoder=json.dumps, \
375+
decoder=json.loads, \
376+
key_factory=lambda: uuid.uuid4().hex)
377+
378+
Create Memcached storage for user session data.
379+
380+
The class is inherited from :class:`~aiohttp_session.AbstractStorage`.
381+
382+
*memcached_conn* is a :class:`~aiomcache.Client` instance::
383+
384+
mc = yield from aiomcache.Client('localhost', 6379)
385+
storage = aiohttp_session.memcached_storage.MemcachedStorage(redis)
386+
387+
Other parameters are the same as for
388+
:class:`~aiohttp_session.AbstractStorage` constructor.

0 commit comments

Comments
 (0)