{ "info": { "author": "Tim Heap", "author_email": "tim@timheap.me", "bugtrack_url": null, "classifiers": [ "Environment :: Web Environment", "Framework :: Django", "Intended Audience :: Developers", "Operating System :: OS Independent", "Programming Language :: Python" ], "description": "==================\ndjango-easyoptions\n==================\n\nEasily add more `Meta`\\esque option classes to your Django forms, models and more.\n\nInstalling\n==========\n\nInstall using pip::\n\n pip install django-easyoptions\n\nIt works with Django 1.4 and upwards.\n\nUsing\n=====\n\nTo make use of Options in your class,\ndefine an Options class, and\nuse one of the metaclass factories provided.\n\n.. code:: python\n\n from django import forms\n from django.utils import six\n from easyoption.options import OptionsBase, form_option_factory\n\n\n # Define your ``Option``\\s container class\n class ExtendedOptions(OptionsBase):\n def __init__(self, options):\n\n # Collect your options, supplying defaults as appropriate\n self.foo = options.pop('foo', None)\n self.frobnicate = options.pop('frobnicate', True)\n\n # Call the ``super().__init__()``, which ensures all options are\n # consumed.\n super(ExtraOption, self).__init__(options)\n\n\n # Define your base class, using the options from ``_extendedoptions``\n class ExtendedForm(six.with_metaclass(\n form_option_factory(ExtendedOptions),\n forms.Form)):\n\n def __init__(self, **kwargs):\n super(ExtendedForm, self).__init__(**kwargs)\n\n if self._extendedoptions.frobnicate:\n self.bar(self._extendedoptions.foo)\n\n\n # Extend your base class, and define the ``ExtendedOptions`` for options\n # for this specific implementation\n class SpecificExtendedForm(ExtendedForm):\n class ExtendedOptions:\n foo = 'quux'\n\nMethods\n-------\n\n``options.options_factory``\n~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nThe main method that does all of the work is\n``options.options_factory``.\nIt generates a new Metaclass that you should apply to your base class,\nallowing subclasses to define their own options.\nThe method accepts four arguments:\n\n``options_processor``\n A callable that processes options the options dict from the class.\n This is usually a class subclassing ``options.OptionsBase``,\n but could be any callable as long as it returns some options structure.\n``options_class_name``\n The name of the attribute on the class where the options definition can be found.\n\n Defaults to the ``options_processor.__name__``, which works well with classes.\n``options_attr_name``\n The name of the attribute where processed options will be stored.\n\n Defaults to ``'_' + options_class_name.lower()``.\n``metaclass``\n The base metaclass to extend.\n Many Django classes have metaclasses already,\n so if you're adding options to class that already has a metaclass,\n you must supply it here for the class to work properly.\n\n Defaults to ``type``.\n\n``options.form_options_factory``\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nCalls ``options.options_factory``\nwith the ``metaclass`` already set to the metaclass for Django forms.\n\n``options.modelform_options_factory``\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nCalls ``options.options_factory``\nwith the ``metaclass`` already set to the metaclass for Django model forms.\n", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://bitbucket.org/tim_heap/django-easyoptions", "keywords": null, "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "django-easyoptions", "package_url": "https://pypi.org/project/django-easyoptions/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-easyoptions/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://bitbucket.org/tim_heap/django-easyoptions" }, "release_url": "https://pypi.org/project/django-easyoptions/0.1.0/", "requires_dist": null, "requires_python": null, "summary": "Easily create extra Meta option classes on forms", "version": "0.1.0" }, "last_serial": 1130093, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "048a0fcf7633118d2b41a2098f4d6e3a", "sha256": "7cf29e7097f84f8a319624b082d34b4eda19d2ebf80f3315c37eda7e38a5fa28" }, "downloads": -1, "filename": "django-easyoptions-0.1.0.tar.gz", "has_sig": false, "md5_digest": "048a0fcf7633118d2b41a2098f4d6e3a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3841, "upload_time": "2014-06-19T06:49:46", "url": "https://files.pythonhosted.org/packages/00/a5/57f22358c12d1af03d2de004b725e4eeb64e4f3159aa6d1d98586c2d88b3/django-easyoptions-0.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "048a0fcf7633118d2b41a2098f4d6e3a", "sha256": "7cf29e7097f84f8a319624b082d34b4eda19d2ebf80f3315c37eda7e38a5fa28" }, "downloads": -1, "filename": "django-easyoptions-0.1.0.tar.gz", "has_sig": false, "md5_digest": "048a0fcf7633118d2b41a2098f4d6e3a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3841, "upload_time": "2014-06-19T06:49:46", "url": "https://files.pythonhosted.org/packages/00/a5/57f22358c12d1af03d2de004b725e4eeb64e4f3159aa6d1d98586c2d88b3/django-easyoptions-0.1.0.tar.gz" } ] }