Skip to main content

BeakerHelpers is a Beaker extension that can show the active sessions and clean the old ones. Currently it only works with beaker.ext.database storage backend.

BeakerHelpers is also a namespace package so new plugins can be created under this namespace.

You can find the Git repository at github.com

Installation

easy_install:

$ <env>/bin/easy_install BeakerHelpers

pip:

$ <env>/bin/pip install BeakerHelpers

Get / Show Sessions Usage

You can call get_sessions to get a list of active sessions (dicts):

>>> import sqlalchemy
>>> from beakerhelpers.sessions import get_sessions
>>> sessions_table = sqlalchemy.Table('beaker_cache',
...     sqlalchemy.MetaData('sqlite:///my.db'), autoload=True)
>>> get_sessions(sessions_table, timeout=3600)  # timeout in seconds
[{
    '_accessed_time': datetime.datetime(2010, 1, 1, 10, 10, 10),
    '_creation_time': datetime.datetime(2010, 1, 1, 08, 40, 00),
    'user_name': u'john@doe.com',
}]

The above form is suitable for Python access. If you want to provide this data to the user you could use show_sessions with the same parameters instead:

>>> print show_sessions(sessions_table, timeout=3600)
--------------------------------------------------------
     _accessed_time |      _creation_time |    user_name
--------------------------------------------------------
2010-01-01 10:10:10 | 2010-01-01 08:40:00 | john@doe.com

However you can use paster beakersessions to call the show_sessions from the console:

$ <env>/bin/paster beakersessions cfg/prod.ini
--------------------------------------------------------
     _accessed_time |      _creation_time |    user_name
--------------------------------------------------------
2010-01-01 10:10:10 | 2010-01-01 08:40:00 | john@doe.com

In this case the cfg/prod.ini file should be a paste.deploy loadable configuration file. BeakerHelpers expects to find these keys in the [app:main] section of cfg/prod.ini:

  • beaker.session.type = ext:database - the only supported backend (yet)

  • beaker.session.url - an SQLAlchemy engine URL

  • beaker.session.timeout - session timeout in seconds

  • beaker.session.table_name - (optional) session storage table. According to beaker.ext.database, defaults to beaker_cache.

paster beakersessions command also takes two optional arguments:

  • --prefix, -p - beaker key prefix in the config file, defaults to beaker.session

  • --timeout, -t - do not show sessions older than the timeout. Timeout examples:

    • 3s - 3 seconds

    • 14m - 14 minutes

    • 36h - 36 hours

    • 2d - 2 days

    • 0 - show all sessions (ignore timeout even in the config file)

    If not provided the timeout will be taken from the config file, <prefix>.timeout (seconds).

Session Cleanup Usage

You can use cleanup_sessions from your Python scripts to remove old sessions:

>>> import sqlalchemy
>>> from beakerhelpers.sessions import cleanup_sessions
>>> sessions_table = sqlalchemy.Table('beaker_cache',
...     sqlalchemy.MetaData('sqlite:///my.db'), autoload=True)
>>> cleanup_sessions(sessions_table, timeout=3600)  # timeout in seconds

The sessions older than 1 hour would get cleaned. However, session cleanup is particularly convenient to be called as a paste script:

$ <env>/bin/paster beakercleanup cfg/prod.ini

It expects the same config file structure and takes the same optional arguments as beakersessions. However, in this case sessions older than --timeout will be removed.

Attention - BeakerShowSessions and BeakerCleanup users

Due to namespace issues BeakerShowSessions and BeakerCleanup can not be installed with pip and/or easy_install. Their functionality got merged into this package and access became simpler. We strongly encourage to use BeakerHelpers instead.

Metadata

Release files for BeakerHelpers 0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for BeakerHelpers 0.1
File Size Uploaded Provenance Actions
BeakerHelpers-0.1.tar.gz 5.4 kB Without provenance Details for BeakerHelpers-0.1.tar.gz

Release files / BeakerHelpers-0.1.tar.gz

Download URL BeakerHelpers-0.1.tar.gz
Size 5.4 kB
Tags Source
SHA-256 checksum
How to use checksums
ef43b66b7c707aa43ec4482ea753c5859431d3e5dea60cb079e2124aec16063a
BLAKE2b-256 checksum
How to use checksums
44b6ba157a2ec7c6842949a5900c7114c4d66a269e9346ba498b14216861ab67
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for BeakerHelpers 0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page