Skip to main content

A easy way to manage resource within request context

Project description

Request Context Manager

Purpose of Request Context

When application begins handling request, request context manager create a request context. Within request context, you could access the attributes bound with the context. If you try to access attributes outside the context, OutsideContext exception will be raised.

How to Create Request Context Manager

from request_context_manager import RequestContextManager
from request_context_manager import RequestContextAttr

# create request context manager
your_request_context_manager = RequestContextManager('your_request_context_manager_name')

# bind request context attribute
class YourRequestContextAttr:
    _request_context_manager = your_request_context_manager

    your_attr = RequestContextAttr('your_attr_name', _request_context_manager)

# get/set request context attribute within request context
with your_request_context_manager.under_request_context():
    YourRequestContextAttr.your_attr.set("hello world")
    your_attr_value = YourRequestContextAttr.your_attr.get() # "hello world"

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

request_context_manager-0.0.3.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

request_context_manager-0.0.3-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file request_context_manager-0.0.3.tar.gz.

File metadata

File hashes

Hashes for request_context_manager-0.0.3.tar.gz
Algorithm Hash digest
SHA256 49eb81e0ad33ec732c9c02653b6884fdced1cba48276fac99e2fb7e363aff17f
MD5 c5b0a901ea8db68b88618475e99a6aac
BLAKE2b-256 7c65affea8fd185ab5a94159968c43b3865babe6455ff40ed6cd85726c1fe6bc

See more details on using hashes here.

File details

Details for the file request_context_manager-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for request_context_manager-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4b5201c834f8a7426fd4d7d17f47e54117c60f869f88cad566432d5c2cbdae12
MD5 0dfce105ae75ed989d68a78736c7878a
BLAKE2b-256 cb8b088d904730f4ac99cef90a0087181598098875c885f9d0e28449dffa8fd5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page