{ "info": { "author": "Nick Joyce", "author_email": "nick.joyce@realkinetic.com", "bugtrack_url": null, "classifiers": [], "description": "Flask-Context\n=============\n\nSupply an arbitrary context object to Flask and use it in your application.\n\nAfter many years of writing apps, we (Real Kinetic) decided that one of the\nmost pragmatic things you can do for the long term stabilty and maintainability\nof your app is to use and pass round a context object that has access to all\nthe business level state that you need. This should be passed around everywhere\nso when debugging you can figure out what request the problem occurred in.\n\nOne of the simplest examples is that of a correlation id. Let's imagine a\nmicroservice environment with a single request that comes in from the outside\nis potentially handled by one or more services. When you start distributing\nrequests like that it becomes really hard to debug errors when they occur. It\nwould be extremely useful if a unique token was used to tie all of the\nprocessing done by the various services together so that any logging aggregation\ncould make it easy to get a better picture of what happened. This is where\nprojects like openzipkin come in.\n\nOther examples may include passing round a ``user_id`` for the request.\n\nThis library extracts the Flask specifics so the engineer can focus on the\nbusiness problem.\n\nUsage\n-----\n\n```python\nimport uuid\nfrom flask import Flask\nfrom flask_context import FlaskContext, current_context\n\n\nclass MyContext(object):\n def __init__(self, correlation_id=None):\n self.correlation_id = correlation_id or uuid.uuid4().hex\n\n\napp = Flask(__name__)\n\nflask_ctx = FlaskContext(MyContext, app)\n\n\n@app.route('/')\ndef index():\n return current_context.correlation_id\n\n\nif __name__ == '__main__':\n app.run('127.0.0.1', 5000)\n```\n\nHead on over to ``http://127.0.0.1:5000/'`` and you should see a unique id\neverytime you refresh the page.\n\nDevelopment\n-----------\n\nSetting up:\n\n```bash\n$ mkvirtualenv flask-context\n(flask-context) $ pip install -r requirements_dev.txt\n```\n\nRunning the tests:\n\n```bash\n(flask-context) $ nosetests --with-coverage\n```\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/RealKinetic/Flask-Context", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "Flask-Context", "package_url": "https://pypi.org/project/Flask-Context/", "platform": "", "project_url": "https://pypi.org/project/Flask-Context/", "project_urls": { "Homepage": "https://github.com/RealKinetic/Flask-Context" }, "release_url": "https://pypi.org/project/Flask-Context/0.1/", "requires_dist": [ "flask", "werkzeug" ], "requires_python": "", "summary": "Provide an arbitrary context object to Flask. Useful for microservice environments.", "version": "0.1" }, "last_serial": 2935056, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "9e3301257adbc68271532f8691487ed7", "sha256": "7233563f516a070cddeda780c3c69535daca2adef1991cfec33dd1c926c9b5fa" }, "downloads": -1, "filename": "Flask_Context-0.1-py2-none-any.whl", "has_sig": false, "md5_digest": "9e3301257adbc68271532f8691487ed7", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 6765, "upload_time": "2017-06-08T10:50:15", "url": "https://files.pythonhosted.org/packages/1d/cc/89e3662a04b7ef742646db210556130f8412de9804a83cfc30ebb234ebf6/Flask_Context-0.1-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "9d63ed53a1e6cc08c6cd69fdee2c8b30", "sha256": "6fa3e63d4cc301a77bd28d091350086aec94db40523c756ca2c812f49679d731" }, "downloads": -1, "filename": "Flask-Context-0.1.tar.gz", "has_sig": false, "md5_digest": "9d63ed53a1e6cc08c6cd69fdee2c8b30", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4020, "upload_time": "2017-06-08T10:50:16", "url": "https://files.pythonhosted.org/packages/a2/eb/312e595da93bea0bc8f0c609cd5c4bbd550876319db61cc4c7c4209202f4/Flask-Context-0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "9e3301257adbc68271532f8691487ed7", "sha256": "7233563f516a070cddeda780c3c69535daca2adef1991cfec33dd1c926c9b5fa" }, "downloads": -1, "filename": "Flask_Context-0.1-py2-none-any.whl", "has_sig": false, "md5_digest": "9e3301257adbc68271532f8691487ed7", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 6765, "upload_time": "2017-06-08T10:50:15", "url": "https://files.pythonhosted.org/packages/1d/cc/89e3662a04b7ef742646db210556130f8412de9804a83cfc30ebb234ebf6/Flask_Context-0.1-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "9d63ed53a1e6cc08c6cd69fdee2c8b30", "sha256": "6fa3e63d4cc301a77bd28d091350086aec94db40523c756ca2c812f49679d731" }, "downloads": -1, "filename": "Flask-Context-0.1.tar.gz", "has_sig": false, "md5_digest": "9d63ed53a1e6cc08c6cd69fdee2c8b30", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4020, "upload_time": "2017-06-08T10:50:16", "url": "https://files.pythonhosted.org/packages/a2/eb/312e595da93bea0bc8f0c609cd5c4bbd550876319db61cc4c7c4209202f4/Flask-Context-0.1.tar.gz" } ] }