This release is a pre-release and may not be stable for production use.
edgecontext.py
Documentation: https://reddit-edgecontext.readthedocs.io/en/latest/
Services deep within the backend often need to know information about the client that originated the request, such as what user is authenticated or what country they're in. Baseplate services can get this information from the edge context which is automatically propagated along with calls between services.
This library provides a Thrift specification of an edge context payload and a
corresponding implementation of the EdgeContextFactory interface from
Baseplate.py.
Usage
Add the EdgeContextFactory to application startup:
from baseplate import Baseplate
from baseplate.lib.secrets import secrets_store_from_config
from reddit_edgecontext import EdgeContextFactory
def make_processor(app_config):
secrets = secrets_store_from_config(app_config, timeout=60)
edgecontext_factory = EdgeContextFactory(secrets)
# pass edgecontext_factory to your framework's integration
# for Thrift: baseplate.frameworks.thrift.baseplateify_processor
# for Pyramid: baseplate.frameworks.pyramid.BaseplateConfigurator
Then read fields while handling requests:
def my_view(request):
return request.edgecontext.user.id
See the documentation for all the available fields.
Development
A Dockerfile is provided to get a development environment running. To use it, build the base Docker image:
$ docker build -t edgecontext .
And then fire up the environment and use the provided Makefile targets to do common tasks:
$ docker run -it -v $PWD:/src -w /src edgecontext
$ make fmt
The following make targets are provided:
fmt: Apply automatic formatting to the source code.thrift: Generate code from the Thrift IDL. Runfmtafter doing this.lint: Run linters on the code.test: Run the test suite.docs: Build the docs. Output can be found inbuild/html/.
The generated Thrift code is committed to the Git repo, so if you change
reddit_edgecontext/edgecontext.thrift make sure to run make thrift fmt and
commit those changes as well.
Metadata
Release files for reddit-edgecontext 1.0.0a4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| reddit_edgecontext-1.0.0a4.tar.gz | 20.4 kB | Without provenance | Details for reddit_edgecontext-1.0.0a4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| reddit_edgecontext-1.0.0a4-py3-none-any.whl | Python 3 | none | any | Details for reddit_edgecontext-1.0.0a4-py3-none-any.whl |
Total release size: 31.9 kB
Release files / reddit_edgecontext-1.0.0a4.tar.gz
| Download URL | reddit_edgecontext-1.0.0a4.tar.gz |
|---|---|
| Size | 20.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4d92c713852441f8eff0d23a121c63f3687cd1e00f738b8ddba3780c2d30d645
|
|
BLAKE2b-256 checksum How to use checksums |
18fefa597f370c4338b34e567754aaae0f0d0561454e831c01293ce8b32605b5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.7.0 requests/2.25.1 setuptools/47.3.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.8.7
|
Release files / reddit_edgecontext-1.0.0a4-py3-none-any.whl
| Download URL | reddit_edgecontext-1.0.0a4-py3-none-any.whl |
|---|---|
| Size | 11.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2666a6ac72f00b0302bcd4403bdb46d37bb0ed133540a135e6fe3a472bc74bd2
|
|
BLAKE2b-256 checksum How to use checksums |
af93e0238aaa2c7b305664cdb95619dbf31576bb86f7aa951eab98fc1ed37584
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.7.0 requests/2.25.1 setuptools/47.3.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.8.7
|
Security for reddit-edgecontext 1.0.0a4
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.