ó
¸9—^c           @   sÚ   d  d l  m Z d  d l m Z d  d l m Z y d  d l m Z Wn! e k
 rg d  d l	 m Z n Xd e
 f d „  ƒ  YZ d e
 f d „  ƒ  YZ d	 e
 f d
 „  ƒ  YZ d e
 f d „  ƒ  YZ d e
 f d „  ƒ  YZ d S(   iÿÿÿÿ(   t   ImproperlyConfigured(   t   redirect(   t
   force_text(   t   resolvet   SetHeadlineMixinc           B   s&   e  Z d  Z d Z d „  Z d „  Z RS(   sš   
    Mixin allows you to set a static headline through a static property on the
    class or programmatically by overloading the get_headline method.
    c         K   s6   t  t |  ƒ j |   } | j i |  j ƒ  d 6ƒ | S(   Nt   headline(   t   superR   t   get_context_datat   updatet   get_headline(   t   selft   kwargs(    (    s5   /tmp/pip-unpacked-wheel-20cZHT/braces/views/_other.pyR      s    c         C   s:   |  j  d  k r- t d j |  j j ƒ ƒ ‚ n  t |  j  ƒ S(   NsO   {0} is missing a headline. Define {0}.headline, or override {0}.get_headline().(   R   t   NoneR    t   formatt	   __class__t   __name__R   (   R
   (    (    s5   /tmp/pip-unpacked-wheel-20cZHT/braces/views/_other.pyR	      s
    N(   R   t
   __module__t   __doc__R   R   R   R	   (    (    (    s5   /tmp/pip-unpacked-wheel-20cZHT/braces/views/_other.pyR   
   s   	t   StaticContextMixinc           B   s&   e  Z d  Z d Z d „  Z d „  Z RS(   s\   
    Mixin allows you to set static context through a static property on
    the class.
    c         K   sl   t  t |  ƒ j |   } y | j |  j ƒ  ƒ Wn2 t t f k
 rc t d j |  j	 j
 ƒ ƒ ‚ n X| Sd  S(   NsC   {0}.static_context must be a dictionary or container of two-tuples.(   R   R   R   R   t   get_static_contextt	   TypeErrort
   ValueErrorR    R   R   R   (   R
   R   (    (    s5   /tmp/pip-unpacked-wheel-20cZHT/braces/views/_other.pyR   )   s    c         C   s4   |  j  d  k r- t d j |  j j ƒ ƒ ‚ n  |  j  S(   Nsk   {0} is missing the static_context property. Define {0}.static_context, or override {0}.get_static_context()(   t   static_contextR   R    R   R   R   (   R
   (    (    s5   /tmp/pip-unpacked-wheel-20cZHT/braces/views/_other.pyR   5   s
    N(   R   R   R   R   R   R   R   (    (    (    s5   /tmp/pip-unpacked-wheel-20cZHT/braces/views/_other.pyR   "   s   	t   CanonicalSlugDetailMixinc           B   s    e  Z d  Z d „  Z d „  Z RS(   s  
    A mixin that enforces a canonical slug in the url.

    If a urlpattern takes a object's pk and slug as arguments and the slug url
    argument does not equal the object's canonical slug, this mixin will
    redirect to the url containing the canonical slug.
    c         O   sù   | |  _  | |  _ | |  _ |  j ƒ  } |  j j |  j d  ƒ } t | j ƒ } | j	 } | j
 | j ƒ d j | ƒ } t | d ƒ r” | j ƒ  }	 n |  j ƒ  }	 |	 | k rÝ i | j |  j 6|	 |  j 6t d 6}
 t | |
  St t |  ƒ j | | | Ž S(   Nt   :t   get_canonical_slugt	   permanent(   t   requestt   argsR   t
   get_objectt   gett   slug_url_kwargR   R   t	   path_infot
   namespacest   appendt   url_namet   joint   hasattrR   t   pkt   pk_url_kwargt   TrueR   R   R   t   dispatch(   R
   R   R   R   t   objt   slugt   matcht	   url_partst   current_urlpatternt   canonical_slugt   params(    (    s5   /tmp/pip-unpacked-wheel-20cZHT/braces/views/_other.pyR)   G   s&    				

c         C   s   |  j  ƒ  j S(   s÷   
        Override this method to customize what slug should be considered
        canonical.

        Alternatively, define the get_canonical_slug method on this view's
        object class. In that case, this method will never be called.
        (   R   R+   (   R
   (    (    s5   /tmp/pip-unpacked-wheel-20cZHT/braces/views/_other.pyR   g   s    (   R   R   R   R)   R   (    (    (    s5   /tmp/pip-unpacked-wheel-20cZHT/braces/views/_other.pyR   ?   s   	 t   AllVerbsMixinc           B   s   e  Z d  Z d Z d „  Z RS(   sº   Call a single method for all HTTP verbs.

    The name of the method should be specified using the class attribute
    ``all_handler``. The default value of this attribute is 'all'.
    t   allc         O   sO   |  j  s' t d j |  j j ƒ ƒ ‚ n  t |  |  j  |  j ƒ } | | | | Ž S(   Ns1   {0} requires the all_handler attribute to be set.(   t   all_handlerR    R   R   R   t   getattrt   http_method_not_allowed(   R
   R   R   R   t   handler(    (    s5   /tmp/pip-unpacked-wheel-20cZHT/braces/views/_other.pyR)   z   s    	(   R   R   R   R3   R)   (    (    (    s5   /tmp/pip-unpacked-wheel-20cZHT/braces/views/_other.pyR1   r   s   t   HeaderMixinc           B   s&   e  Z d  Z i  Z d „  Z d „  Z RS(   s•   
    Add arbitrary HTTP headers to a response by specifying them in the
    ``headers`` attribute or by overriding the ``get_headers()`` method.
    c         C   s   |  j  S(   N(   t   headers(   R
   R   (    (    s5   /tmp/pip-unpacked-wheel-20cZHT/braces/views/_other.pyt   get_headers‹   s    c         O   sa   t  t |  ƒ j | | | Ž } x< |  j | ƒ j ƒ  D]% \ } } | | k r4 | | | <q4 q4 W| S(   s¸   
        Override this method to customize the way additional headers are
        retrieved.  It is mandatory that the returned value supports the
        ``.items()`` method.
        (   R   R7   R)   R9   t   items(   R
   R   R   R   t   responset   keyt   value(    (    s5   /tmp/pip-unpacked-wheel-20cZHT/braces/views/_other.pyR)   Ž   s
    "(   R   R   R   R8   R9   R)   (    (    (    s5   /tmp/pip-unpacked-wheel-20cZHT/braces/views/_other.pyR7   „   s   	N(   t   django.core.exceptionsR    t   django.shortcutsR   t   django.utils.encodingR   t   django.urlsR   t   ImportErrort   django.core.urlresolverst   objectR   R   R   R1   R7   (    (    (    s5   /tmp/pip-unpacked-wheel-20cZHT/braces/views/_other.pyt   <module>   s   3