{ "info": { "author": "Fusinobox, Inc.", "author_email": "programmers@fusionbox.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Programming Language :: Python", "Topic :: Software Development :: Libraries" ], "description": "======================\nDjango-DecoratorMixins\n======================\n\nA collection of class-based view mixins for\nDjango. Django-Decoratormixins also includes a function for converting\nview decorators into class-based view mixins.\n\n-----\nUsage\n-----\n\nIf you have a decorator, usage is as simple as calling\n``DecoratorMixin`` and passing the decorator as the argument.\n\n.. code:: python\n\n from decoratormixins import DecoratorMixin\n\n def my_decorator(f):\n # ...\n\n MyDecMixin = DecoratorMixin(my_decorator)\n\n~~~~~~~~~~~~~~~~~~~\nDecorator Factories\n~~~~~~~~~~~~~~~~~~~\n\nMany of Django's built in decorators are actually decorator\nfactories. In this case, it is necessary to get a decorator out of\nthem before it is possible to create a mixin from it.\n\nHere we have a decorator factory that modifies a view to require a\ncertain parameter in a get request:\n\n.. code:: python\n\n def require_get_param(param):\n def actual_decorator(view_func):\n @wraps(view_func)\n def _wrapped_view_func(request, *args, **kwargs):\n if request.GET.get(param, None) is not None:\n response = view_func(request, *args, **kwargs)\n response.content += param\n return response\n else:\n return HttpResponseNotFound(\"{} is not present.\".format(param))\n\n return _wrapped_view_func\n return actual_decorator\n\nIn order to use it, we must specify the parameter we are requiring:\n\n.. code:: python\n\n require_foo_decorator = require_get_param('foo')\n\nAnd now we can call DecoratorMixin on that decorator:\n\n.. code:: python\n\n RequireFooMixin = DecoratorMixin(require_foo_decorator)\n\n~~~~~~~~~~~~~~~\nApplying Mixins\n~~~~~~~~~~~~~~~\n\nOnce you have the mixin you reqire, mix it in with a class-based view.\n\n.. code:: python\n\n class TestView(View):\n def get(self, request):\n return HttpResponse(\"OK\")\n\n class TestViewFoo(RequireFooMixin, TestView):\n pass\n\n``TestViewFoo.as_view()`` will return a view method that is usable in\nyour ``urls.py``.\n\n~~~~~~~~~~~~~~~~\nComposing Mixins\n~~~~~~~~~~~~~~~~\n\nIt is possible to use multiple mixins for a single class, but **order\nmatters**. The leftmost mixin in a class definition will be the\noutermost decorator.\n\n.. code:: python\n\n from decoratormixins.auth import LoginRequiredMixin\n from decoratormixins.http import RequireGetMixin\n\n # TestView from above\n\n class LoggedInGetRequestView(LoginRequiredMixin,\n RequireGetMixin,\n\t\t\t TestView):\n pass\n\n---------------\nIncluded Mixins\n---------------\n\nHere is a list of all of the included mixins, and the modules in which they can be found.\n\n* ``decoratormixins.auth``\n\n - ``LoginRequiredMixin``\n\n* ``decoratormixins.csrf``\n\n - ``CsrfProtectMixin``\n - ``EnsureCsrfCookieMixin``\n - ``CsrfExemptMixin``\n\n* ``decoratormixins.http``\n\n - ``ConditionalPageMixin``\n - ``RequireGetMixin``\n - ``RequirePostMixin``\n - ``RequireSafeMixin``\n - ``EtagMixin``\n - ``LastModifiedMixin``\n\n* ``decoratormixins.cache``\n\n - ``NeverCacheMixin``\n\n* ``decoratormixins.clickjacking``\n\n - ``XFrameOptionsDenyMixin``\n - ``XFrameOptionsDenySameoriginMixin``\n - ``XFrameOptionsDenyExemptMixin``", "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/fusionbox/django-decoratormixins", "keywords": "django decorator mixin class-based-views class based views", "license": "BSD", "maintainer": null, "maintainer_email": null, "name": "django-decoratormixins", "package_url": "https://pypi.org/project/django-decoratormixins/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-decoratormixins/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/fusionbox/django-decoratormixins" }, "release_url": "https://pypi.org/project/django-decoratormixins/1.0.0/", "requires_dist": null, "requires_python": null, "summary": "A collection of decorator mixins for Django views.", "version": "1.0.0" }, "last_serial": 1732271, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "63faf8ff70469c2f678ee6c84ecee3ca", "sha256": "e2bfd247abed08b0e2245da362a0b43b7149ca2f132da8231019416bf9bb59bf" }, "downloads": -1, "filename": "django-decoratormixins-1.0.0.tar.gz", "has_sig": false, "md5_digest": "63faf8ff70469c2f678ee6c84ecee3ca", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4020, "upload_time": "2015-09-21T21:55:47", "url": "https://files.pythonhosted.org/packages/09/23/e379e4b9ee77fcf8f97e27c0a469189bf807e08d850623c086ccfbb68af4/django-decoratormixins-1.0.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "63faf8ff70469c2f678ee6c84ecee3ca", "sha256": "e2bfd247abed08b0e2245da362a0b43b7149ca2f132da8231019416bf9bb59bf" }, "downloads": -1, "filename": "django-decoratormixins-1.0.0.tar.gz", "has_sig": false, "md5_digest": "63faf8ff70469c2f678ee6c84ecee3ca", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4020, "upload_time": "2015-09-21T21:55:47", "url": "https://files.pythonhosted.org/packages/09/23/e379e4b9ee77fcf8f97e27c0a469189bf807e08d850623c086ccfbb68af4/django-decoratormixins-1.0.0.tar.gz" } ] }