Skip to main content

No project description provided

Project description

Muffin-Session – Implement an user sessions in Muffin Framework.

Build Status http://img.shields.io/pypi/v/muffin-session.svg?style=flat-square http://img.shields.io/pypi/dm/muffin-session.svg?style=flat-square Donate

Requirements

  • python >= 3.3

Installation

Muffin-Session should be installed using pip:

pip install muffin-session

Usage

  • Add muffin_session to PLUGINS in your Application configuration.

  • Setup options if needed (see bellow).

Options

SESSION_DEFAULT_USER_CHECKER – A function which checks logged user (lambda x: x)

SESSION_LOGIN_URL – Redirect URL (‘/login’)

SESSION_SECRET – A secret code (‘Insecuresecret’)

SESSION_AUTO_LOAD – Load session every request automatically

Session will be loaded into request.session.

Examples

@app.ps.session.user_loader
def load_user(_id):
    """Define your own user loader. """

@app.register('/session')
def get_session(request):
    """ Load session and return it as JSON. """
    session = yield from app.ps.session(request)
    return dict(session)

@app.register('/admin')
@app.ps.session.user_pass(lambda u: u.is_admin)
def admin(request):
    """ Check for user is admin. """


@app.register('/login')
def login(request):
    """ Login user. """
    # ...
    yield from app.ps.session.login(current_user.pk)


@app.register('/logout')
    """ Logout user. """
    # ...
    yield from app.ps.session.logout(curuser.pk)

Bug tracker

If you have any suggestions, bug reports or annoyances please report them to the issue tracker at https://github.com/klen/muffin-session/issues

Contributing

Development of Muffin-Session happens at: https://github.com/klen/muffin-session

Contributors

  • klen (Kirill Klenov)

License

Licensed under a MIT license.

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

muffin-session-0.0.7.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

muffin_session-0.0.7-py2.py3-none-any.whl (6.4 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file muffin-session-0.0.7.tar.gz.

File metadata

File hashes

Hashes for muffin-session-0.0.7.tar.gz
Algorithm Hash digest
SHA256 0722e51a548a773176cbeadee7b839756f7ac8ff1b0aed7b9e72b39b646dde46
MD5 a3998bce59ebae9c408c5d6ec92b5567
BLAKE2b-256 a7c3eae026d7f01c3d0bde0202ee7303a207b04826c1ccfa2bf345717af901de

See more details on using hashes here.

File details

Details for the file muffin_session-0.0.7-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for muffin_session-0.0.7-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 555dee0a6a6d309c955868d54dfc44f4fbfe34fb6eb4458e0b3a33b708400a6c
MD5 7b2e3647d5930bb3ebbd1e8db7fe36dc
BLAKE2b-256 b9ecd25e56fe95dc9861c60a090139c11d2993f3e70d92f656d5ca429f61f35b

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