Module Expr Str ImportFrom alias ImportFrom alias TryExcept body Import alias identifier handlers ExceptHandler type NameLoad body Import alias ImportFrom alias ClassDef bases NameLoad body Expr Str FunctionDef arguments args NameParam defaults vararg kwarg body Expr Str If Call NameLoad NameLoad NameLoad body Return Call AttributeLoad Call NameLoad NameLoad NameLoad attr NameLoad Return Call AttributeLoad Call NameLoad NameLoad NameLoad attr NameLoad SubscriptLoad NameLoad Slice Num decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str If Call NameLoad NameLoad NameLoad body Expr Call AttributeLoad Call NameLoad NameLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr orelse Expr Call AttributeLoad Call NameLoad NameLoad NameLoad attr Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return AttributeLoad AttributeLoad NameLoad attr attr decorator_list NameLoad FunctionDef arguments args NameParam defaults body Expr Str Return AttributeLoad AttributeLoad NameLoad attr attr decorator_list NameLoad FunctionDef arguments args NameParam defaults body Expr Str Return AttributeLoad AttributeLoad NameLoad attr attr decorator_list NameLoad FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore AttributeLoad NameLoad attr If Call NameLoad NameLoad NameLoad body Return NameLoad If CompareNotIn NameLoad AttributeLoad NameLoad attr body Assign NameStore Call NameLoad BinOpMod Str Call AttributeLoad AttributeLoad NameLoad attr attr Assign SubscriptStore AttributeLoad NameLoad attr Index NameLoad Call NameLoad NameLoad TupleLoad NameLoad NameLoad Dict Str NameLoad Return SubscriptLoad AttributeLoad NameLoad attr Index NameLoad decorator_list NameLoad FunctionDef arguments args NameParam defaults body Expr Str Return TupleLoad NameLoad TupleLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return Call NameLoad AttributeLoad NameLoad attr decorator_list Assign NameStore Dict decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assign NameStore Call AttributeLoad NameLoad attr NameLoad Return Call NameLoad NameLoad NameLoad decorator_list ClassDef bases NameLoad body Expr Str Assign NameStore NameLoad FunctionDef arguments args NameParam NameParam defaults body Expr Str Assert CompareLtELtE Num Call NameLoad NameLoad Num BinOpMod Str TupleLoad NameLoad Assign NameStore Call AttributeLoad Call NameLoad NameLoad NameLoad attr NameLoad SubscriptLoad NameLoad Slice Num Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Index Num Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Index Num Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Index Num Assign AttributeStore NameLoad attr TupleLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr If CompareEq Call NameLoad NameLoad Num body For TupleStore NameStore NameStore Call AttributeLoad SubscriptLoad NameLoad Index Num attr body Expr Call NameLoad NameLoad NameLoad NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str If CompareIs NameLoad NameLoad body Raise Call NameLoad Str Return Call NameLoad AttributeLoad NameLoad attr NameLoad NameLoad decorator_list decorator_list
N/A N/A Provides classes used to construct a full ``Choices`` instance.

Notes
-----

The documentation format in this file is numpydoc_.

.. _numpydoc: https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt

 __future__ unicode_literals builtins object N/A N/A N/A cPickle pickle N/A N/A N/A ImportError N/A N/A pickle django.utils.functional Promise ChoiceAttributeMixin N/A object N/A N/A Base class to represent an attribute of a ``ChoiceEntry``.

    Used for ``constant``, ``name``, and ``display``.

    It must be used as a mixin with another type, and the final class will be a type with
    added attributes to access the ``ChoiceEntry`` instance and its attributes.

    Attributes
    ----------
    choice_entry : instance of ``ChoiceEntry``
        The ``ChoiceEntry`` instance that hold the current value, used to access its constant,
        value and display name.
    constant : property
        Returns the choice field holding the constant of the attached ``ChoiceEntry``.
    value : property
        Returns the choice field holding the value of the attached ``ChoiceEntry``.
    display : property
        Returns the choice field holding the display name of the attached ``ChoiceEntry``.
    original_value : ?
        The value used to create the current instance.
    creator_type : type
        The class that created a new class. Will be ``ChoiceAttributeMixin`` except if it was
        overridden by the author.

    Example
    -------

    Classes can be created manually:

    >>> class IntChoiceAttribute(ChoiceAttributeMixin, int): pass
    >>> field = IntChoiceAttribute(1, ChoiceEntry(('FOO', 1, 'foo')))
    >>> field
    1
    >>> field.constant, field.value, field.display
    (u'FOO', 1, u'foo')
    >>> field.choice_entry
    (u'FOO', 1, u'foo')

    Or via the ``get_class_for_value`` class method:

    >>> klass = ChoiceAttributeMixin.get_class_for_value(1.5)
    >>> klass.__name__
    'FloatChoiceAttribute'
    >>> float in klass.mro()
    True

     __new__ N/A N/A cls N/A args kwargs N/A N/A Construct the object (the other class used with this mixin).

        Notes
        -----

        Only passes the very first argument to the ``super`` constructor.
        All others are not needed for the other class, only for this mixin.

         N/A N/A issubclass cls Promise N/A N/A N/A N/A N/A super ChoiceAttributeMixin cls __new__ cls N/A N/A N/A N/A super ChoiceAttributeMixin cls __new__ cls N/A args N/A 1 N/A __init__ N/A N/A self value choice_entry N/A N/A N/A Initiate the object to save the value and the choice entry.

        Parameters
        ----------
        value : ?
            Value to pass to the ``super`` constructor (for the other class using this mixin)
        choice_entry: ChoiceEntry
            The ``ChoiceEntry`` instance that hold the current value, used to access its constant,
            value and display name.

        Notes
        -----

        Call the ``super`` constructor with only the first value, as the other class doesn't
        expect the ``choice_entry`` parameter.

         N/A N/A isinstance self Promise N/A N/A N/A N/A N/A super ChoiceAttributeMixin self __init__ N/A value _proxy____args N/A value _proxy____kw N/A N/A N/A N/A N/A super ChoiceAttributeMixin self __init__ N/A N/A self original_value value N/A N/A self choice_entry choice_entry N/A constant N/A N/A self N/A N/A N/A Property that returns the ``constant`` attribute of the attached ``ChoiceEntry``. N/A N/A N/A self choice_entry constant N/A property value N/A N/A self N/A N/A N/A Property that returns the ``value`` attribute of the attached ``ChoiceEntry``. N/A N/A N/A self choice_entry value N/A property display N/A N/A self N/A N/A N/A Property that returns the ``display`` attribute of the attached ``ChoiceEntry``. N/A N/A N/A self choice_entry display N/A property get_class_for_value N/A N/A cls value N/A N/A N/A Class method to construct a class based on this mixin and the type of the given value.

        Parameters
        ----------
        value: ?
            The value from which to extract the type to create the new class.

        Notes
        -----
        The  create classes are cached (in ``cls.__classes_by_type``) to avoid recreating already
        created classes.
         N/A type_ N/A value __class__ N/A N/A issubclass type_ ChoiceAttributeMixin N/A N/A type_ N/A N/A type_ N/A cls _classes_by_type N/A N/A class_name N/A str N/A %sChoiceAttribute N/A N/A N/A type_ __name__ capitalize N/A N/A N/A cls _classes_by_type N/A type_ N/A type class_name N/A cls type_ N/A creator_type cls N/A N/A N/A cls _classes_by_type N/A type_ N/A classmethod __reduce__ N/A N/A self N/A N/A N/A Reducer to make the auto-created classes picklable.

        Returns
        -------
        tuple
            A tuple as expected by pickle, to recreate the object when calling ``pickle.loads``:
            1. a callable to recreate the object
            2. a tuple with all positioned arguments expected by this callable

         N/A N/A create_choice_attribute N/A N/A self creator_type N/A self original_value N/A self choice_entry N/A __bool__ N/A N/A self N/A N/A N/A Use the original value to know if the value is truely of falsy N/A N/A bool N/A self original_value N/A N/A _classes_by_type N/A N/A create_choice_attribute N/A N/A creator_type value choice_entry N/A N/A N/A Create an instance of a subclass of ChoiceAttributeMixin for the given value.

    Parameters
    ----------
    creator_type : type
        ``ChoiceAttributeMixin`` or a subclass, from which we'll call the ``get_class_for_value``
        class-method.
    value : ?
        The value for which we want to create an instance of a new subclass of ``creator_type``.
    choice_entry: ChoiceEntry
        The ``ChoiceEntry`` instance that hold the current value, used to access its constant,
        value and display name.

    Returns
    -------
    ChoiceAttributeMixin
        An instance of a subclass of ``creator_type`` for the given value

     N/A klass N/A N/A creator_type get_class_for_value value N/A N/A klass value choice_entry N/A ChoiceEntry N/A tuple N/A N/A Represents a choice in a ``Choices`` object, with easy access to its attribute.

    Expecting a tuple with three entries. (constant, value, display name), it will add three
    attributes to access then: ``constant``, ``value`` and ``display``.

    By passing a dict after these three first entries, in the tuple, it's alose possible to
    add some other attributes to the ``ChoiceEntry` instance``.

    Parameters
    ----------
    tuple_ : tuple
        A tuple with three entries, the name of the constant, the value, and the display name.
        A dict could be added as a fourth entry to add additional attributes.


    Example
    -------

    >>> entry = ChoiceEntry(('FOO', 1, 'foo'))
    >>> entry
    (u'FOO', 1, u'foo')
    >>> (entry.constant, entry.value, entry.display)
    (u'FOO', 1, u'foo')
    >>> entry.choice
    (1, u'foo')

    You can also pass attributes to add to the instance to create:

    >>> entry = ChoiceEntry(('FOO', 1, 'foo', {'bar': 1, 'baz': 2}))
    >>> entry
    (u'FOO', 1, u'foo')
    >>> entry.bar
    1
    >>> entry.baz
    2

    Raises
    ------
    AssertionError
        If the number of entries in the tuple is not expected. Must be 3 or 4.

     N/A ChoiceAttributeMixin ChoiceAttributeMixin __new__ N/A N/A cls tuple_ N/A N/A N/A Construct the tuple with 3 entries, and save optional attributes from the 4th one. N/A N/A 3 N/A len tuple_ 4 N/A Invalid number of entries in %s N/A tuple_ N/A obj N/A N/A N/A super ChoiceEntry cls __new__ cls N/A tuple_ N/A 3 N/A N/A obj constant N/A N/A obj _get_choice_attribute N/A tuple_ N/A 0 N/A N/A obj value N/A N/A obj _get_choice_attribute N/A tuple_ N/A 1 N/A N/A obj display N/A N/A obj _get_choice_attribute N/A tuple_ N/A 2 N/A N/A obj choice N/A N/A obj value N/A obj display N/A N/A N/A len tuple_ 4 N/A N/A N/A key value N/A N/A N/A tuple_ N/A 3 items N/A N/A N/A setattr obj key value N/A obj N/A _get_choice_attribute N/A N/A self value N/A N/A N/A Get a choice attribute for the given value.

        Parameters
        ----------
        value: ?
            The value for which we want a choice attribute.

        Returns
        -------
        An instance of a class based on ``ChoiceAttributeMixin`` for the given value.

        Raises
        ------
        ValueError
            If the value is None, as we cannot really subclass NoneType.

         N/A N/A value None N/A N/A N/A ValueError Using `None` in a `Choices` object is not supported. You may use an empty string. N/A N/A create_choice_attribute N/A self ChoiceAttributeMixin value self N/A N/A