ó
`¾Tc           @   s\   d  Z  d d l m Z d d l m Z m Z d e f d „  ƒ  YZ d e f d „  ƒ  YZ d	 S(
   s   
    flask.blueprints
    ~~~~~~~~~~~~~~~~

    Blueprints are the recommended way to implement larger or more
    pluggable applications in Flask 0.7 and later.

    :copyright: (c) 2011 by Armin Ronacher.
    :license: BSD, see LICENSE for more details.
iÿÿÿÿ(   t   update_wrapperi   (   t   _PackageBoundObjectt   _endpoint_from_view_funct   BlueprintSetupStatec           B   s&   e  Z d  Z d „  Z d d d „ Z RS(   sí   Temporary holder object for registering a blueprint with the
    application.  An instance of this class is created by the
    :meth:`~flask.Blueprint.make_setup_state` method and later passed
    to all register callback functions.
    c         C   sÈ   | |  _  | |  _ | |  _ | |  _ |  j j d ƒ } | d  k rQ |  j j } n  | |  _ |  j j d ƒ } | d  k r‡ |  j j } n  | |  _ t |  j j	 ƒ |  _
 |  j
 j |  j j d d ƒ ƒ d  S(   Nt	   subdomaint
   url_prefixt   url_defaults(    (   t   appt	   blueprintt   optionst   first_registrationt   gett   NoneR   R   t   dictt   url_values_defaultsR   t   update(   t   selfR   R   R	   R
   R   R   (    (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyt   __init__   s    						c         K   sª   |  j  r |  j  | } n  | j d |  j ƒ | d k rG t | ƒ } n  |  j } d | k rw t | | j d ƒ  } n  |  j j	 | d |  j
 j | f | d | | d S(   s³   A helper method to register a rule (and optionally a view function)
        to the application.  The endpoint is automatically prefixed with the
        blueprint's name.
        R   t   defaultss   %s.%sN(   R   t
   setdefaultR   R   R   R   R   t   popR   t   add_url_ruleR   t   name(   R   t   rulet   endpointt	   view_funcR	   R   (    (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyR   >   s    		N(   t   __name__t
   __module__t   __doc__R   R   R   (    (    (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyR      s   	&t	   Blueprintc           B   sO  e  Z d  Z e Z e Z d d d d d d d „ Z d „  Z d „  Z	 e d „ Z
 e d „ Z d „  Z d d d „ Z d „  Z d d	 „ Z d d
 „ Z d d „ Z d d „ Z d d „ Z d d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z  d „  Z! d „  Z" d „  Z# RS(   s5  Represents a blueprint.  A blueprint is an object that records
    functions that will be called with the
    :class:`~flask.blueprint.BlueprintSetupState` later to register functions
    or other things on the main application.  See :ref:`blueprints` for more
    information.

    .. versionadded:: 0.7
    c	   	      C   st   t  j |  | | ƒ | |  _ | |  _ | |  _ | |  _ | |  _ g  |  _ i  |  _ | d  k rg i  } n  | |  _
 d  S(   N(   R   R   R   R   R   t   static_foldert   static_url_patht   deferred_functionst   view_functionsR   R   (	   R   R   t   import_nameR   R   t   template_folderR   R   R   (    (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyR   \   s    								c         C   sI   |  j  r5 |  j r5 d d l m } | t d ƒ ƒ n  |  j j | ƒ d S(   sá   Registers a function that is called when the blueprint is
        registered on the application.  This function is called with the
        state as argument as returned by the :meth:`make_setup_state`
        method.
        iÿÿÿÿ(   t   warnsg   The blueprint was already registered once but is getting modified now.  These changes will not show up.N(   t   _got_registered_oncet   warn_on_modificationst   warningsR$   t   WarningR    t   append(   R   t   funcR$   (    (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyt   recordk   s    c            s%   ‡  f d †  } |  j  t | ˆ  ƒ ƒ S(   sý   Works like :meth:`record` but wraps the function in another
        function that will ensure the function is only called once.  If the
        blueprint is registered a second time on the application, the
        function passed is not called.
        c            s   |  j  r ˆ  |  ƒ n  d  S(   N(   R
   (   t   state(   R*   (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyt   wrapper~   s    	(   R+   R    (   R   R*   R-   (    (   R*   sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyt   record_oncex   s    c         C   s   t  |  | | | ƒ S(   sã   Creates an instance of :meth:`~flask.blueprints.BlueprintSetupState`
        object that is later passed to the register callback functions.
        Subclasses can override this to return a subclass of the setup state.
        (   R   (   R   R   R	   R
   (    (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyt   make_setup_stateƒ   s    c         C   so   t  |  _ |  j | | | ƒ } |  j rM | j |  j d d |  j d d ƒn  x |  j D] } | | ƒ qW Wd S(   s>  Called by :meth:`Flask.register_blueprint` to register a blueprint
        on the application.  This can be overridden to customize the register
        behavior.  Keyword arguments from
        :func:`~flask.Flask.register_blueprint` are directly forwarded to this
        method in the `options` dictionary.
        s   /<path:filename>R   R   t   staticN(   t   TrueR%   R/   t   has_static_folderR   R   t   send_static_fileR    (   R   R   R	   R
   R,   t   deferred(    (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyt   registerŠ   s    			
c            s   ‡  ‡ ‡ f d †  } | S(   s™   Like :meth:`Flask.route` but for a blueprint.  The endpoint for the
        :func:`url_for` function is prefixed with the name of the blueprint.
        c            s/   ˆ j  d |  j ƒ } ˆ  j ˆ | |  ˆ  |  S(   NR   (   R   R   R   (   t   fR   (   R   R	   R   (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyt	   decoratorŸ   s    (    (   R   R   R	   R7   (    (   R   R	   R   sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyt   route›   s    c            sD   ˆ  r! d ˆ  k s! t  d ƒ ‚ n  |  j ‡  ‡ ‡ ‡ f d †  ƒ d S(   s    Like :meth:`Flask.add_url_rule` but for a blueprint.  The endpoint for
        the :func:`url_for` function is prefixed with the name of the blueprint.
        t   .s-   Blueprint endpoint's should not contain dot'sc            s   |  j  ˆ ˆ  ˆ ˆ  S(   N(   R   (   t   s(   R   R   R   R	   (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyt   <lambda>«   s    N(   t   AssertionErrorR+   (   R   R   R   R   R	   (    (   R   R   R   R	   sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyR   ¥   s    c            s   ‡  ‡ f d †  } | S(   s\  Like :meth:`Flask.endpoint` but for a blueprint.  This does not
        prefix the endpoint with the blueprint name, this has to be done
        explicitly by the user of this method.  If the endpoint is prefixed
        with a `.` it will be registered to the current blueprint, otherwise
        it's an application independent endpoint.
        c            s#   ‡ ‡  f d †  } ˆ j  | ƒ ˆ  S(   Nc            s   ˆ |  j  j ˆ  <d  S(   N(   R   R!   (   R,   (   R   R6   (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyt   register_endpoint¶   s    (   R.   (   R6   R=   (   R   R   (   R6   sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyR7   µ   s    (    (   R   R   R7   (    (   R   R   sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyR   ®   s    c            s   ‡  ‡ f d †  } | S(   sþ   Register a custom template filter, available application wide.  Like
        :meth:`Flask.template_filter` but for a blueprint.

        :param name: the optional name of the filter, otherwise the
                     function name will be used.
        c            s   ˆ  j  |  d ˆ ƒ|  S(   NR   (   t   add_app_template_filter(   R6   (   R   R   (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyR7   Ã   s    (    (   R   R   R7   (    (   R   R   sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyt   app_template_filter¼   s    c            s#   ‡  ‡ f d †  } |  j  | ƒ d S(   sI  Register a custom template filter, available application wide.  Like
        :meth:`Flask.add_template_filter` but for a blueprint.  Works exactly
        like the :meth:`app_template_filter` decorator.

        :param name: the optional name of the filter, otherwise the
                     function name will be used.
        c            s    ˆ |  j  j j ˆ  p ˆ j <d  S(   N(   R   t	   jinja_envt   filtersR   (   R,   (   R   R6   (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyt   register_templateÐ   s    N(   R.   (   R   R6   R   RB   (    (   R   R6   sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyR>   È   s    c            s   ‡  ‡ f d †  } | S(   s  Register a custom template test, available application wide.  Like
        :meth:`Flask.template_test` but for a blueprint.

        .. versionadded:: 0.10

        :param name: the optional name of the test, otherwise the
                     function name will be used.
        c            s   ˆ  j  |  d ˆ ƒ|  S(   NR   (   t   add_app_template_test(   R6   (   R   R   (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyR7   Ý   s    (    (   R   R   R7   (    (   R   R   sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyt   app_template_testÔ   s    	c            s#   ‡  ‡ f d †  } |  j  | ƒ d S(   sa  Register a custom template test, available application wide.  Like
        :meth:`Flask.add_template_test` but for a blueprint.  Works exactly
        like the :meth:`app_template_test` decorator.

        .. versionadded:: 0.10

        :param name: the optional name of the test, otherwise the
                     function name will be used.
        c            s    ˆ |  j  j j ˆ  p ˆ j <d  S(   N(   R   R@   t   testsR   (   R,   (   R   R6   (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyRB   ì   s    N(   R.   (   R   R6   R   RB   (    (   R   R6   sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyRC   â   s    
c            s   ‡  ‡ f d †  } | S(   s  Register a custom template global, available application wide.  Like
        :meth:`Flask.template_global` but for a blueprint.

        .. versionadded:: 0.10

        :param name: the optional name of the global, otherwise the
                     function name will be used.
        c            s   ˆ  j  |  d ˆ ƒ|  S(   NR   (   t   add_app_template_global(   R6   (   R   R   (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyR7   ù   s    (    (   R   R   R7   (    (   R   R   sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyt   app_template_globalð   s    	c            s#   ‡  ‡ f d †  } |  j  | ƒ d S(   si  Register a custom template global, available application wide.  Like
        :meth:`Flask.add_template_global` but for a blueprint.  Works exactly
        like the :meth:`app_template_global` decorator.

        .. versionadded:: 0.10

        :param name: the optional name of the global, otherwise the
                     function name will be used.
        c            s    ˆ |  j  j j ˆ  p ˆ j <d  S(   N(   R   R@   t   globalsR   (   R,   (   R   R6   (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyRB     s    N(   R.   (   R   R6   R   RB   (    (   R   R6   sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyRF   þ   s    
c            s   ˆ  j  ‡  ‡ f d †  ƒ ˆ S(   s´   Like :meth:`Flask.before_request` but for a blueprint.  This function
        is only executed before each request that is handled by a function of
        that blueprint.
        c            s"   |  j  j j ˆ  j g  ƒ j ˆ ƒ S(   N(   R   t   before_request_funcsR   R   R)   (   R:   (   R   R6   (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyR;     s   (   R.   (   R   R6   (    (   R   R6   sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyt   before_request  s    c            s   |  j  ‡  f d †  ƒ ˆ  S(   s…   Like :meth:`Flask.before_request`.  Such a function is executed
        before each request, even if outside of a blueprint.
        c            s   |  j  j j d  g  ƒ j ˆ  ƒ S(   N(   R   RI   R   R   R)   (   R:   (   R6   (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyR;     s   (   R.   (   R   R6   (    (   R6   sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyt   before_app_request  s    c            s   |  j  ‡  f d †  ƒ ˆ  S(   sƒ   Like :meth:`Flask.before_first_request`.  Such a function is
        executed before the first request to the application.
        c            s   |  j  j j ˆ  ƒ S(   N(   R   t   before_first_request_funcsR)   (   R:   (   R6   (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyR;   !  s    (   R.   (   R   R6   (    (   R6   sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyt   before_app_first_request  s    c            s   ˆ  j  ‡  ‡ f d †  ƒ ˆ S(   s²   Like :meth:`Flask.after_request` but for a blueprint.  This function
        is only executed after each request that is handled by a function of
        that blueprint.
        c            s"   |  j  j j ˆ  j g  ƒ j ˆ ƒ S(   N(   R   t   after_request_funcsR   R   R)   (   R:   (   R   R6   (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyR;   )  s   (   R.   (   R   R6   (    (   R   R6   sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyt   after_request$  s    c            s   |  j  ‡  f d †  ƒ ˆ  S(   s™   Like :meth:`Flask.after_request` but for a blueprint.  Such a function
        is executed after each request, even if outside of the blueprint.
        c            s   |  j  j j d  g  ƒ j ˆ  ƒ S(   N(   R   RN   R   R   R)   (   R:   (   R6   (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyR;   1  s   (   R.   (   R   R6   (    (   R6   sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyt   after_app_request-  s    c            s   ˆ  j  ‡  ‡ f d †  ƒ ˆ S(   s=  Like :meth:`Flask.teardown_request` but for a blueprint.  This
        function is only executed when tearing down requests handled by a
        function of that blueprint.  Teardown request functions are executed
        when the request context is popped, even when no actual request was
        performed.
        c            s"   |  j  j j ˆ  j g  ƒ j ˆ ƒ S(   N(   R   t   teardown_request_funcsR   R   R)   (   R:   (   R   R6   (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyR;   <  s   (   R.   (   R   R6   (    (   R   R6   sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyt   teardown_request5  s    c            s   |  j  ‡  f d †  ƒ ˆ  S(   s°   Like :meth:`Flask.teardown_request` but for a blueprint.  Such a
        function is executed when tearing down each request, even if outside of
        the blueprint.
        c            s   |  j  j j d  g  ƒ j ˆ  ƒ S(   N(   R   RQ   R   R   R)   (   R:   (   R6   (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyR;   E  s   (   R.   (   R   R6   (    (   R6   sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyt   teardown_app_request@  s    c            s   ˆ  j  ‡  ‡ f d †  ƒ ˆ S(   s   Like :meth:`Flask.context_processor` but for a blueprint.  This
        function is only executed for requests handled by a blueprint.
        c            s"   |  j  j j ˆ  j g  ƒ j ˆ ƒ S(   N(   R   t   template_context_processorsR   R   R)   (   R:   (   R   R6   (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyR;   M  s   (   R.   (   R   R6   (    (   R   R6   sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyt   context_processorI  s    c            s   |  j  ‡  f d †  ƒ ˆ  S(   s—   Like :meth:`Flask.context_processor` but for a blueprint.  Such a
        function is executed each request, even if outside of the blueprint.
        c            s   |  j  j j d  g  ƒ j ˆ  ƒ S(   N(   R   RT   R   R   R)   (   R:   (   R6   (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyR;   U  s   (   R.   (   R   R6   (    (   R6   sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyt   app_context_processorQ  s    c            s   ‡  ‡ f d †  } | S(   s   Like :meth:`Flask.errorhandler` but for a blueprint.  This
        handler is used for all requests, even if outside of the blueprint.
        c            s   ˆ j  ‡ ‡  f d †  ƒ ˆ  S(   Nc            s   |  j  j ˆ  ƒ ˆ ƒ S(   N(   R   t   errorhandler(   R:   (   t   codeR6   (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyR;   ^  s    (   R.   (   R6   (   R   RX   (   R6   sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyR7   ]  s    (    (   R   RX   R7   (    (   R   RX   sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyt   app_errorhandlerY  s    c            s   ˆ  j  ‡  ‡ f d †  ƒ ˆ S(   sµ   Registers a function as URL value preprocessor for this
        blueprint.  It's called before the view functions are called and
        can modify the url values provided.
        c            s"   |  j  j j ˆ  j g  ƒ j ˆ ƒ S(   N(   R   t   url_value_preprocessorsR   R   R)   (   R:   (   R   R6   (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyR;   g  s   (   R.   (   R   R6   (    (   R   R6   sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyt   url_value_preprocessorb  s    c            s   ˆ  j  ‡  ‡ f d †  ƒ ˆ S(   s§   Callback function for URL defaults for this blueprint.  It's called
        with the endpoint and values and should update the values passed
        in place.
        c            s"   |  j  j j ˆ  j g  ƒ j ˆ ƒ S(   N(   R   t   url_default_functionsR   R   R)   (   R:   (   R   R6   (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyR;   p  s   (   R.   (   R   R6   (    (   R   R6   sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyR   k  s    c            s   |  j  ‡  f d †  ƒ ˆ  S(   sE   Same as :meth:`url_value_preprocessor` but application wide.
        c            s   |  j  j j d  g  ƒ j ˆ  ƒ S(   N(   R   RZ   R   R   R)   (   R:   (   R6   (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyR;   w  s   (   R.   (   R   R6   (    (   R6   sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyt   app_url_value_preprocessort  s    c            s   |  j  ‡  f d †  ƒ ˆ  S(   s;   Same as :meth:`url_defaults` but application wide.
        c            s   |  j  j j d  g  ƒ j ˆ  ƒ S(   N(   R   R\   R   R   R)   (   R:   (   R6   (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyR;   ~  s   (   R.   (   R   R6   (    (   R6   sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyt   app_url_defaults{  s    c            s   ‡  ‡ f d †  } | S(   s	  Registers an error handler that becomes active for this blueprint
        only.  Please be aware that routing does not happen local to a
        blueprint so an error handler for 404 usually is not handled by
        a blueprint unless it is caused inside a view function.  Another
        special case is the 500 internal server error which is always looked
        up from the application.

        Otherwise works as the :meth:`~flask.Flask.errorhandler` decorator
        of the :class:`~flask.Flask` object.
        c            s    ˆ j  ‡ ‡ ‡  f d †  ƒ ˆ  S(   Nc            s   |  j  j ˆ  j ˆ ˆ ƒ S(   N(   R   t   _register_error_handlerR   (   R:   (   R   t   code_or_exceptionR6   (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyR;   Ž  s   	(   R.   (   R6   (   R   R`   (   R6   sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyR7     s    (    (   R   R`   R7   (    (   R   R`   sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyRW   ‚  s    N($   R   R   R   t   FalseR&   R%   R   R   R+   R.   R/   R5   R8   R   R   R?   R>   RD   RC   RG   RF   RJ   RK   RM   RO   RP   RR   RS   RU   RV   RY   R[   R   R]   R^   RW   (    (    (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyR   O   sD   			
																						N(	   R   t	   functoolsR    t   helpersR   R   t   objectR   R   (    (    (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/blueprints.pyt   <module>   s   >