{ "info": { "author": "Gregor M\u00c3\u00bcllegger", "author_email": "gregor@muellegger.de", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Web Environment", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python" ], "description": "django-pandora\n==============\n\n*This is Pandora's box. Don't open it if you cannot live with the\nconsequences.*\n\n**django-pandora** is a utility library for django that lets you easily store\nvalues in a thread-local. This makes it possible to introduce global variables\nthat are thread safe and don't interfere with other requests to the server.\n\nHowever a global state is a common anti-pattern in software development that\nyou usually want to avoid. But at the end of the day it might be the easiest\nway to solve some of your problems.\n\nThe most common use case for **django-pandora** might be to store the current\nrequest in Pandora's box to make it available in places of your code that\ndoesn't get the request passed in as argument.\n\nInstallation\n------------\n\n#. ``pip install django-pandora``\n#. Add ``'pandora.middleware.RequestMiddleware'`` to your\n ``MIDDLEWARE_CLASSES`` setting. (optional)\n\nUsage\n-----\n\nThe ``pandora.box`` object implements a dict like interface which you can use\nto store thread local values. It's really as simple as using a dictionary::\n\n >>> from pandora import box\n >>> box['foo'] = 'Hello world!'\n >>> box['foo']\n 'Hello world!'\n >>> 'foo' in box\n True\n >>> 'bar' in box\n False\n >>> box['bar']\n Traceback (most recent call last):\n ...\n KeyError: 'bar'\n >>> box.get('bar', None)\n None\n\nAs mentioned above, you might want to use the box to store the current request\nobject. Pandora ships with a custom middleware for this purpose. Just append\n``'pandora.middleware.RequestMiddleware'`` to your ``MIDDLEWARE_CLASSES``\nsetting. You can then access the request with ``box['request']``.\n\nThere is also another middleware that stores the current user object in\n``box['user']``. To use this, add ``'pandora.middleware.UserMiddleware'`` to\nyour ``MIDDLEWARE_CLASSES`` setting, but make sure that it is listed *after*\n``'django.contrib.auth.middleware.AuthenticationMiddleware'``.\n\nTips\n----\n\n* You don't need to import the box object into your module if you think the name\n is too generic and might clash with some of your local names. Just use ::\n\n >>> import pandora\n >>> pandora.box['request']\n ...\n\n* Even if opening Pandora's box might not seem too evil at the first glance,\n please try to avoid it and pass the request object or any other dependency\n around where possible. Having a global state makes things more difficult for\n everyone - especially to reliably test your code.\n\n* Read the `Wikipedia article about Pandora's box\n `_.\n\n\nChanglog\n========\n\n0.1.0\n-----\n\nInitial release.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/gregmuellegger/django-pandora", "keywords": null, "license": "BSD", "maintainer": null, "maintainer_email": null, "name": "django-pandora", "package_url": "https://pypi.org/project/django-pandora/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-pandora/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/gregmuellegger/django-pandora" }, "release_url": "https://pypi.org/project/django-pandora/0.1.0/", "requires_dist": null, "requires_python": null, "summary": "Opening Pandora's box by making django's request object available in a thread local.", "version": "0.1.0" }, "last_serial": 713440, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "5543669b9d1dfbb51ae58eea6c4678d7", "sha256": "1b278d9cc8882f6b56d24937e544ff7caa2028444bb50196c30db26e19a950a7" }, "downloads": -1, "filename": "django-pandora-0.1.0.tar.gz", "has_sig": false, "md5_digest": "5543669b9d1dfbb51ae58eea6c4678d7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4417, "upload_time": "2010-11-25T22:29:54", "url": "https://files.pythonhosted.org/packages/bd/4e/64762278dedc96e8e521eaffb2cd9fe7df744fecf90b23e27927499201df/django-pandora-0.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "5543669b9d1dfbb51ae58eea6c4678d7", "sha256": "1b278d9cc8882f6b56d24937e544ff7caa2028444bb50196c30db26e19a950a7" }, "downloads": -1, "filename": "django-pandora-0.1.0.tar.gz", "has_sig": false, "md5_digest": "5543669b9d1dfbb51ae58eea6c4678d7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4417, "upload_time": "2010-11-25T22:29:54", "url": "https://files.pythonhosted.org/packages/bd/4e/64762278dedc96e8e521eaffb2cd9fe7df744fecf90b23e27927499201df/django-pandora-0.1.0.tar.gz" } ] }