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

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_AUTO_LOAD – Load session every request automatically Session will be loaded into request.session.

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

SESSION_LOGIN_URL – Redirect URL (‘/login’), or it may be a function which accepts request object and returns a string.

SESSION_SECRET – A secret code (‘Insecuresecret’)

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.

If you wish to express your appreciation for the project, you are welcome to send a postcard to:

Kirill Klenov
pos. Severny 8-3
MO, Istra, 143500
Russia

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.2.0.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

muffin_session-0.2.0-py2.py3-none-any.whl (6.9 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

File hashes

Hashes for muffin-session-0.2.0.tar.gz
Algorithm Hash digest
SHA256 446ee2160d32ef2bd04750cb91ea065394b9006d84690a5f342e0f09b13bb36a
MD5 3d8bb00ca242831dd585751d0fcfdbe0
BLAKE2b-256 a95e7c52dd108762664b584255a837b5f3b127a36dd480e64f994205f8b5ac66

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for muffin_session-0.2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 e610b12cab30b514801285dccddfc59574ce7b6c6629fabcc268f4b51bed1951
MD5 43a0cb70dd4ac7b153af26dfcf525c95
BLAKE2b-256 755addbe6e961dd842f18b0ec9c7e81e694871022e5faaf78301aa614f21cd38

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