
`Tc           @   s  d  Z  d d l Z d d l Z d d l m Z d d l m Z d d l m Z d d l	 m
 Z
 d d l m Z d d l m Z m Z m Z m Z d d	 l m Z m Z m Z m Z d
 d l m Z m Z m Z m Z m Z m Z d
 d l m Z d
 d l  m! Z! m" Z" d
 d l# m$ Z$ m% Z% d
 d l& m' Z' m( Z( m) Z) d
 d l* m+ Z+ m, Z, m- Z- m. Z. d
 d l/ m0 Z0 d
 d l1 m2 Z2 d
 d l3 m4 Z4 m5 Z5 m6 Z6 d
 d l7 m8 Z8 m9 Z9 m: Z: m; Z; m< Z< d
 d l= m> Z> m? Z? m@ Z@ mA ZA e   ZB d   ZC d   ZD d e f d     YZE d S(   s   
    flask.app
    ~~~~~~~~~

    This module implements the central WSGI application object.

    :copyright: (c) 2011 by Armin Ronacher.
    :license: BSD, see LICENSE for more details.
iN(   t   Lock(   t	   timedelta(   t   chain(   t   update_wrapper(   t   ImmutableDict(   t   Mapt   Rulet   RequestRedirectt
   BuildError(   t   HTTPExceptiont   InternalServerErrort   MethodNotAllowedt
   BadRequesti   (   t   _PackageBoundObjectt   url_fort   get_flashed_messagest   locked_cached_propertyt   _endpoint_from_view_funct   find_package(   t   json(   t   Requestt   Response(   t   ConfigAttributet   Config(   t   RequestContextt
   AppContextt   _AppCtxGlobals(   t   _request_ctx_stackt   requestt   sessiont   g(   t   SecureCookieSessionInterface(   t   blueprint_is_module(   t   DispatchingJinjaLoadert   Environmentt   _default_template_ctx_processor(   t   request_startedt   request_finishedt   got_request_exceptiont   request_tearing_downt   appcontext_tearing_down(   t   reraiset   string_typest	   text_typet   integer_typesc         C   s    t  |  t  s t d |   S|  S(   Nt   seconds(   t
   isinstanceR   (   t   value(    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyt   _make_timedelta+   s    c            s     f d   } t  |    S(   sk   Wraps a method so that it performs a check in debug mode if the
    first request was already handled.
    c            s1   |  j  r! |  j r! t d   n    |  | |  S(   Nsm  A setup function was called after the first request was handled.  This usually indicates a bug in the application where a module was not imported and decorators or other functionality was called too late.
To fix this make sure to import all your view modules, database models and everything related at a central place before the application starts serving requests.(   t   debugt   _got_first_requestt   AssertionError(   t   selft   argst   kwargs(   t   f(    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyt   wrapper_func5   s    (   R   (   R7   R8   (    (   R7   sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyt   setupmethod1   s    
t   Flaskc           B   s   e  Z d  Z e Z e Z e Z d   Z	 d   Z
 e e	 e
  Z [	 [
 e d  Z e d  Z e d  Z e d  Z e d d e Z e d	  Z e d
  Z e Z d d d d d d d Z e j Z e j Z e d d d g  Z e i e  d 6e  d 6dr d 6dr d 6dr d 6e" d d  d 6e  d	 6dr d
 6dr d 6dr d 6d d 6dr d 6dr d 6e d 6e  d 6dr d 6dt d! 6e  d" 6e  d# 6d$ d% 6e d& 6e d' 6e d( 6 Z# e$ Z% dr Z& e'   Z( dr dr d) d* dr e  d+  Z) d,   Z* d-   Z+ e e* e+  Z, [* [+ e- d.    Z. e d/    Z/ e d0    Z0 e d1    Z1 e- d2    Z2 e d3    Z3 e  d4  Z4 d5   Z5 d6 d7  Z6 d8   Z7 d9   Z8 d:   Z9 d;   Z: d<   Z; dr dr dr d=  Z< e d>  Z= d?   Z> d@   Z? dA   Z@ dB   ZA eB dC    ZC eB dr dr dD   ZD dE   ZE eB dF    ZF eB dG    ZG dH   ZH eB dI    ZI eB dr dJ   ZJ eB dr dK   ZK eB dr dL   ZL eB dr dM   ZM eB dr dN   ZN eB dr dO   ZO eB dP    ZP eB dQ    ZQ eB dR    ZR eB dS    ZS eB dT    ZT eB dU    ZU eB dV    ZV eB dW    ZW dX   ZX dY   ZY dZ   ZZ d[   Z[ d\   Z\ d]   Z] d^   Z^ d_   Z_ d`   Z` da   Za db   Zb dc   Zc dd   Zd de   Ze df   Zf dg   Zg dh   Zh dr di  Zi dr dj  Zj dk   Zk dl   Zl dm   Zm dn   Zn e do    Zo dp   Zp dq   Zq RS(u   s  The flask object implements a WSGI application and acts as the central
    object.  It is passed the name of the module or package of the
    application.  Once it is created it will act as a central registry for
    the view functions, the URL rules, template configuration and much more.

    The name of the package is used to resolve resources from inside the
    package or the folder the module is contained in depending on if the
    package parameter resolves to an actual python package (a folder with
    an `__init__.py` file inside) or a standard module (just a `.py` file).

    For more information about resource loading, see :func:`open_resource`.

    Usually you create a :class:`Flask` instance in your main module or
    in the `__init__.py` file of your package like this::

        from flask import Flask
        app = Flask(__name__)

    .. admonition:: About the First Parameter

        The idea of the first parameter is to give Flask an idea what
        belongs to your application.  This name is used to find resources
        on the file system, can be used by extensions to improve debugging
        information and a lot more.

        So it's important what you provide there.  If you are using a single
        module, `__name__` is always the correct value.  If you however are
        using a package, it's usually recommended to hardcode the name of
        your package there.

        For example if your application is defined in `yourapplication/app.py`
        you should create it with one of the two versions below::

            app = Flask('yourapplication')
            app = Flask(__name__.split('.')[0])

        Why is that?  The application will work even with `__name__`, thanks
        to how resources are looked up.  However it will make debugging more
        painful.  Certain extensions can make assumptions based on the
        import name of your application.  For example the Flask-SQLAlchemy
        extension will look for the code in your application that triggered
        an SQL query in debug mode.  If the import name is not properly set
        up, that debugging information is lost.  (For example it would only
        pick up SQL queries in `yourapplication.app` and not
        `yourapplication.views.frontend`)

    .. versionadded:: 0.7
       The `static_url_path`, `static_folder`, and `template_folder`
       parameters were added.

    .. versionadded:: 0.8
       The `instance_path` and `instance_relative_config` parameters were
       added.

    :param import_name: the name of the application package
    :param static_url_path: can be used to specify a different path for the
                            static files on the web.  Defaults to the name
                            of the `static_folder` folder.
    :param static_folder: the folder with static files that should be served
                          at `static_url_path`.  Defaults to the ``'static'``
                          folder in the root path of the application.
    :param template_folder: the folder that contains the templates that should
                            be used by the application.  Defaults to
                            ``'templates'`` folder in the root path of the
                            application.
    :param instance_path: An alternative instance path for the application.
                          By default the folder ``'instance'`` next to the
                          package or module is assumed to be the instance
                          path.
    :param instance_relative_config: if set to `True` relative filenames
                                     for loading the config are assumed to
                                     be relative to the instance path instead
                                     of the application root.
    c         C   s   |  j  S(   N(   t   app_ctx_globals_class(   R4   (    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyt   _get_request_globals_class   s    c         C   s-   d d l  m } | t d   | |  _ d  S(   Ni(   t   warnsC   request_globals_class attribute is now called app_ctx_globals_class(   t   warningsR=   t   DeprecationWarningR;   (   R4   R/   R=   (    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyt   _set_request_globals_class   s    t   DEBUGt   TESTINGt
   SECRET_KEYt   SESSION_COOKIE_NAMEt   PERMANENT_SESSION_LIFETIMEt   get_convertert   USE_X_SENDFILEt   LOGGER_NAMEt   -iP   s   
s7   %(levelname)s in %(module)s [%(pathname)s:%(lineno)d]:
s   %(message)s
t
   extensionss   jinja2.ext.autoescapes   jinja2.ext.with_t   PROPAGATE_EXCEPTIONSt   PRESERVE_CONTEXT_ON_EXCEPTIONt   daysi   t   SERVER_NAMEt   APPLICATION_ROOTR   t   SESSION_COOKIE_DOMAINt   SESSION_COOKIE_PATHt   SESSION_COOKIE_HTTPONLYt   SESSION_COOKIE_SECUREt   MAX_CONTENT_LENGTHi   i<   t   SEND_FILE_MAX_AGE_DEFAULTt   TRAP_BAD_REQUEST_ERRORSt   TRAP_HTTP_EXCEPTIONSt   httpt   PREFERRED_URL_SCHEMEt   JSON_AS_ASCIIt   JSON_SORT_KEYSt   JSONIFY_PRETTYPRINT_REGULARt   statict	   templatesc   	      C   s  t  j |  | d | | d  k	 rQ d d l m } | t d  d d | } n  | d  k	 ri | |  _ n  | d  k	 r | |  _ n  | d  k r |  j   } n! t	 j
 j |  s t d   n  | |  _ |  j |  |  _ d  |  _ |  j |  _ i  |  _ i  |  _ i |  j d  6|  _ g  |  _ i  |  _ g  |  _ i  |  _ i  |  _ g  |  _ i  |  _ i  |  _ i t g d  6|  _ i  |  _  i  |  _! t"   |  _# t$ |  _% t&   |  _' |  j( r|  j) |  j d d	 d
 d |  j* n  d  S(   Nt   template_folderi(   R=   s)   static_path is now called static_url_patht
   stackleveli   sX   If an instance path is provided it must be absolute.  A relative path was given instead.s   /<path:filename>t   endpointR]   t	   view_func(+   R   t   __init__t   NoneR>   R=   R?   t   static_url_patht   static_foldert   auto_find_instance_patht   ost   patht   isabst
   ValueErrort   instance_patht   make_configt   configt   _loggert   import_namet   logger_namet   view_functionst   _error_handlerst   error_handler_spect   url_build_error_handlerst   before_request_funcst   before_first_request_funcst   after_request_funcst   teardown_request_funcst   teardown_appcontext_funcst   url_value_preprocessorst   url_default_functionsR#   t   template_context_processorst
   blueprintsRJ   R   t   url_mapt   FalseR2   R    t   _before_request_lockt   has_static_foldert   add_url_rulet   send_static_file(	   R4   Rp   t   static_pathRe   Rf   R_   Rl   t   instance_relative_configR=   (    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyRc   ;  sR    												
						c         C   s-   d d l  m } | t d  d d |  j S(   Ni(   R=   sO   error_handlers is deprecated, use the new error_handler_spec attribute instead.R`   i   (   R>   R=   R?   Rs   (   R4   R=   (    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyt   _get_error_handlers  s    c         C   s   | |  _  | |  j d  <d  S(   N(   Rs   Rt   Rd   (   R4   R/   (    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyt   _set_error_handlers  s    	c         C   s_   |  j  d k rX t t j d d d  } | d k r8 d St j j t j j |   d S|  j  S(   s_  The name of the application.  This is usually the import name
        with the difference that it's guessed from the run file if the
        import name is main.  This name is used as a display name when
        Flask needs the name of the application.  It can be set and overridden
        to change the value.

        .. versionadded:: 0.8
        t   __main__t   __file__i    N(	   Rp   t   getattrt   syst   modulesRd   Rh   Ri   t   splitextt   basename(   R4   t   fn(    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyt   name
  s    
 c         C   s-   |  j  d } | d k	 r | S|  j p, |  j S(   s   Returns the value of the `PROPAGATE_EXCEPTIONS` configuration
        value in case it's set, otherwise a sensible default is returned.

        .. versionadded:: 0.7
        RK   N(   Rn   Rd   t   testingR1   (   R4   t   rv(    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyt   propagate_exceptions  s    c         C   s$   |  j  d } | d k	 r | S|  j S(   s   Returns the value of the `PRESERVE_CONTEXT_ON_EXCEPTION`
        configuration value in case it's set, otherwise a sensible default
        is returned.

        .. versionadded:: 0.7
        RL   N(   Rn   Rd   R1   (   R4   R   (    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyt   preserve_context_on_exception'  s    c      	   C   s   |  j  r% |  j  j |  j k r% |  j  St Q |  j  rQ |  j  j |  j k rQ |  j  Sd d l m } | |   |  _  } | SWd QXd S(   s  A :class:`logging.Logger` object for this application.  The
        default configuration is to log to stderr if the application is
        in debug mode.  This logger can be used to (surprise) log messages.
        Here some examples::

            app.logger.debug('A value for debugging')
            app.logger.warning('A warning occurred (%d apples)', 42)
            app.logger.error('An error occurred')

        .. versionadded:: 0.3
        i(   t   create_loggerN(   Ro   R   Rq   t   _logger_lockt   flask.loggingR   (   R4   R   R   (    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyt   logger4  s    c         C   s
   |  j    S(   s.   The Jinja2 environment used to load templates.(   t   create_jinja_environment(   R4   (    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyt	   jinja_envJ  s    c         C   s   |  j  S(   s   This attribute is set to `True` if the application started
        handling the first request.

        .. versionadded:: 0.8
        (   R2   (   R4   (    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyt   got_first_requestO  s    c         C   s+   |  j  } | r |  j } n  t | |  j  S(   sd  Used to create the config attribute by the Flask constructor.
        The `instance_relative` parameter is passed in from the constructor
        of Flask (there named `instance_relative_config`) and indicates if
        the config should be relative to the instance path or the root path
        of the application.

        .. versionadded:: 0.8
        (   t	   root_pathRl   R   t   default_config(   R4   t   instance_relativeR   (    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyRm   X  s    		c         C   sQ   t  |  j  \ } } | d k r4 t j j | d  St j j | d |  j d  S(   s  Tries to locate the instance path if it was not provided to the
        constructor of the application class.  It will basically calculate
        the path to a folder named ``instance`` next to your main file or
        the package.

        .. versionadded:: 0.8
        t   instancet   vars	   -instanceN(   R   Rp   Rd   Rh   Ri   t   joinR   (   R4   t   prefixt   package_path(    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyRg   f  s    t   rbc         C   s   t  t j j |  j |  |  S(   s  Opens a resource from the application's instance folder
        (:attr:`instance_path`).  Otherwise works like
        :meth:`open_resource`.  Instance resources can also be opened for
        writing.

        :param resource: the name of the resource.  To access resources within
                         subfolders use forward slashes as separator.
        :param mode: resource file opening mode, default is 'rb'.
        (   t   openRh   Ri   R   Rl   (   R4   t   resourcet   mode(    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyt   open_instance_resources  s    
c         C   s   t  |  j  } d | k r+ |  j | d <n  t |  |  } | j j d t d t d |  j d t	 d t
 d t  t j | j d <| S(	   s$  Creates the Jinja2 environment based on :attr:`jinja_options`
        and :meth:`select_jinja_autoescape`.  Since 0.7 this also adds
        the Jinja2 globals and filters after initialization.  Override
        this function to customize the behavior.

        .. versionadded:: 0.5
        t
   autoescapeR   R   Rn   R   R   R   t   tojson(   t   dictt   jinja_optionst   select_jinja_autoescapeR"   t   globalst   updateR   R   Rn   R   R   R   R   t   tojson_filtert   filters(   R4   t   optionsR   (    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyR     s    	c         C   s
   t  |   S(   s  Creates the loader for the Jinja2 environment.  Can be used to
        override just the loader and keeping the rest unchanged.  It's
        discouraged to override this function.  Instead one should override
        the :meth:`jinja_loader` function instead.

        The global loader dispatches between the loaders of the application
        and the individual blueprints.

        .. versionadded:: 0.7
        (   R!   (   R4   (    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyt   create_global_jinja_loader  s    c         C   s   d S(   s   Deprecated.  Used to initialize the Jinja2 globals.

        .. versionadded:: 0.5
        .. versionchanged:: 0.7
           This method is deprecated with 0.7.  Override
           :meth:`create_jinja_environment` instead.
        N(    (   R4   (    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyt   init_jinja_globals  s    c         C   s   | d k r t S| j d  S(   s|   Returns `True` if autoescaping should be active for the given
        template name.

        .. versionadded:: 0.5
        s   .htmls   .htms   .xmls   .xhtmlN(   s   .htmls   .htms   .xmls   .xhtml(   Rd   R   t   endswith(   R4   t   filename(    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyR     s    c         C   s   |  j  d } t j } | d k	 re | j j } | d k	 re | |  j  k re t | |  j  |  } qe n  | j   } x | D] } | j |    qx W| j |  d S(   s  Update the template context with some commonly used variables.
        This injects request, session, config and g into the template
        context as well as everything template context processors want
        to inject.  Note that the as of Flask 0.6, the original values
        in the context will not be overridden if a context processor
        decides to return a value with the same key.

        :param context: the context as a dictionary that is updated in place
                        to add extra variables.
        N(	   R}   Rd   R   t   topR   t	   blueprintR   t   copyR   (   R4   t   contextt   funcst   reqctxt   bpt   orig_ctxt   func(    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyt   update_template_context  s    	c         K   s   d d l  m } | d
 k r% d } n  | d
 k rx |  j d } | ro d | k ro t | j d d  d  } qx d } n  | d
 k	 r t |  |  _ n  | j d |  j  | j d	 |  j  z | | | |  |  Wd
 t	 |  _
 Xd
 S(   s  Runs the application on a local development server.  If the
        :attr:`debug` flag is set the server will automatically reload
        for code changes and show a debugger in case an exception happened.

        If you want to run the application in debug mode, but disable the
        code execution on the interactive debugger, you can pass
        ``use_evalex=False`` as parameter.  This will keep the debugger's
        traceback screen active, but disable code execution.

        .. admonition:: Keep in Mind

           Flask will suppress any server error with a generic error page
           unless it is in debug mode.  As such to enable just the
           interactive debugger without the code reloading, you have to
           invoke :meth:`run` with ``debug=True`` and ``use_reloader=False``.
           Setting ``use_debugger`` to `True` without being in debug mode
           won't catch any exceptions because there won't be any to
           catch.

        .. versionchanged:: 0.10
           The default port is now picked from the ``SERVER_NAME`` variable.

        :param host: the hostname to listen on. Set this to ``'0.0.0.0'`` to
                     have the server available externally as well. Defaults to
                     ``'127.0.0.1'``.
        :param port: the port of the webserver. Defaults to ``5000`` or the
                     port defined in the ``SERVER_NAME`` config variable if
                     present.
        :param debug: if given, enable or disable debug mode.
                      See :attr:`debug`.
        :param options: the options to be forwarded to the underlying
                        Werkzeug server.  See
                        :func:`werkzeug.serving.run_simple` for more
                        information.
        i(   t
   run_simples	   127.0.0.1RN   t   :i   i  t   use_reloadert   use_debuggerN(   t   werkzeug.servingR   Rd   Rn   t   intt   rsplitt   boolR1   t
   setdefaultR   R2   (   R4   t   hostt   portR1   R   R   t   server_name(    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyt   run  s    $		c         C   s>   |  j  } | d k r( d d l m } n  | |  |  j d | S(   s  Creates a test client for this application.  For information
        about unit testing head over to :ref:`testing`.

        Note that if you are testing for assertions or exceptions in your
        application code, you must set ``app.testing = True`` in order for the
        exceptions to propagate to the test client.  Otherwise, the exception
        will be handled by the application (not visible to the test client) and
        the only indication of an AssertionError or other exception will be a
        500 status code response to the test client.  See the :attr:`testing`
        attribute.  For example::

            app.testing = True
            client = app.test_client()

        The test client can be used in a `with` block to defer the closing down
        of the context until the end of the `with` block.  This is useful if
        you want to access the context locals for testing::

            with app.test_client() as c:
                rv = c.get('/?vodka=42')
                assert request.args['vodka'] == '42'

        See :class:`~flask.testing.FlaskClient` for more information.

        .. versionchanged:: 0.4
           added support for `with` block usage for the client.

        .. versionadded:: 0.7
           The `use_cookies` parameter was added as well as the ability
           to override the client to be used by setting the
           :attr:`test_client_class` attribute.
        i(   t   FlaskClientt   use_cookiesN(   t   test_client_classRd   t   flask.testingR   t   response_class(   R4   R   t   cls(    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyt   test_client  s    !	c         C   s   |  j  j |  |  S(   sP  Creates or opens a new session.  Default implementation stores all
        session data in a signed cookie.  This requires that the
        :attr:`secret_key` is set.  Instead of overriding this method
        we recommend replacing the :class:`session_interface`.

        :param request: an instance of :attr:`request_class`.
        (   t   session_interfacet   open_session(   R4   R   (    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyR   1  s    c         C   s   |  j  j |  | |  S(   s  Saves the session if it needs updates.  For the default
        implementation, check :meth:`open_session`.  Instead of overriding this
        method we recommend replacing the :class:`session_interface`.

        :param session: the session to be saved (a
                        :class:`~werkzeug.contrib.securecookie.SecureCookie`
                        object)
        :param response: an instance of :attr:`response_class`
        (   R   t   save_session(   R4   R   t   response(    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyR   ;  s    
c         C   s   |  j  j |   S(   s   Creates a new instance of a missing session.  Instead of overriding
        this method we recommend replacing the :class:`session_interface`.

        .. versionadded:: 0.7
        (   R   t   make_null_session(   R4   (    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyR   G  s    c         K   sr   t  |  s t d   |  j s4 t d |   n* d d l m } | t d |  d d |  j | |  d S(	   sn  Registers a module with this application.  The keyword argument
        of this function are the same as the ones for the constructor of the
        :class:`Module` class and will override the values of the module if
        provided.

        .. versionchanged:: 0.7
           The module system was deprecated in favor for the blueprint
           system.
        sU   register_module requires actual module objects.  Please upgrade to blueprints though.sL   Module support was disabled but code attempted to register a module named %ri(   R=   s   Modules are deprecated.  Upgrade to using blueprints.  Have a look into the documentation for more information.  If this module was registered by a Flask-Extension upgrade the extension or contact the author of that extension instead.  (Registered %r)R`   i   N(   R    R3   t   enable_modulest   RuntimeErrorR>   R=   R?   t   register_blueprint(   R4   t   moduleR   R=   (    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyt   register_moduleO  s    
		
c         K   s   t  } | j |  j k rW |  j | j | k sm t d | |  j | j | j f   n | |  j | j <t } | j |  | |  d S(   sQ   Registers a blueprint on the application.

        .. versionadded:: 0.7
        s   A blueprint's name collision occurred between %r and %r.  Both share the same name "%s".  Blueprints that are created on the fly need unique names.N(   R   R   R~   R3   t   Truet   register(   R4   R   R   t   first_registration(    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyR   i  s    #c   	      K   s|  | d	 k r t |  } n  | | d <| j d d	  } | d	 k r^ t | d d	  pX d
 } n  t |  } t t | d d   } t | d d	  } | d	 k r d | k r t } | j d  q t } n  | | O} | j d  p d	 | d <|  j	 | d | | } | | _
 |  j j |  | d	 k	 rx|  j j |  } | d	 k	 rh| | k rht d |   n  | |  j | <n  d	 S(   sw  Connects a URL rule.  Works exactly like the :meth:`route`
        decorator.  If a view_func is provided it will be registered with the
        endpoint.

        Basically this example::

            @app.route('/')
            def index():
                pass

        Is equivalent to the following::

            def index():
                pass
            app.add_url_rule('/', 'index', index)

        If the view_func is not provided you will need to connect the endpoint
        to a view function like so::

            app.view_functions['index'] = index

        Internally :meth:`route` invokes :meth:`add_url_rule` so if you want
        to customize the behavior via subclassing you only need to change
        this method.

        For more information refer to :ref:`url-route-registrations`.

        .. versionchanged:: 0.2
           `view_func` parameter added.

        .. versionchanged:: 0.6
           `OPTIONS` is added automatically as method.

        :param rule: the URL rule as string
        :param endpoint: the endpoint for the registered URL rule.  Flask
                         itself assumes the name of the view function as
                         endpoint
        :param view_func: the function to call when serving a request to the
                          provided endpoint
        :param options: the options to be forwarded to the underlying
                        :class:`~werkzeug.routing.Rule` object.  A change
                        to Werkzeug is handling of method options.  methods
                        is a list of methods this rule should be limited
                        to (`GET`, `POST` etc.).  By default a rule
                        just listens for `GET` (and implicitly `HEAD`).
                        Starting with Flask 0.6, `OPTIONS` is implicitly
                        added and handled by the standard request handling.
        Ra   t   methodst   GETt   required_methodst   provide_automatic_optionst   OPTIONSt   defaultssF   View function mapping is overwriting an existing endpoint function: %sN(   R   (    (   Rd   R   t   popR   t   setR   t   addR   t   gett   url_rule_classR   R   Rr   R3   (	   R4   t   ruleRa   Rb   R   R   R   R   t   old_func(    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyR   {  s4    2
	
	c            s       f d   } | S(   s  A decorator that is used to register a view function for a
        given URL rule.  This does the same thing as :meth:`add_url_rule`
        but is intended for decorator usage::

            @app.route('/')
            def index():
                return 'Hello World'

        For more information refer to :ref:`url-route-registrations`.

        :param rule: the URL rule as string
        :param endpoint: the endpoint for the registered URL rule.  Flask
                         itself assumes the name of the view function as
                         endpoint
        :param options: the options to be forwarded to the underlying
                        :class:`~werkzeug.routing.Rule` object.  A change
                        to Werkzeug is handling of method options.  methods
                        is a list of methods this rule should be limited
                        to (`GET`, `POST` etc.).  By default a rule
                        just listens for `GET` (and implicitly `HEAD`).
                        Starting with Flask 0.6, `OPTIONS` is implicitly
                        added and handled by the standard request handling.
        c            s,    j  d d   }   j  | |    |  S(   NRa   (   R   Rd   R   (   R7   Ra   (   R4   R   R   (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyt	   decorator  s    (    (   R4   R   R   R   (    (   R4   R   R   sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyt   route  s    c            s      f d   } | S(   s   A decorator to register a function as an endpoint.
        Example::

            @app.endpoint('example.endpoint')
            def example():
                return "example"

        :param endpoint: the name of the endpoint
        c            s   |    j   <|  S(   N(   Rr   (   R7   (   R4   Ra   (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyR     s    (    (   R4   Ra   R   (    (   R4   Ra   sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyRa     s    c            s      f d   } | S(   s  A decorator that is used to register a function give a given
        error code.  Example::

            @app.errorhandler(404)
            def page_not_found(error):
                return 'This page does not exist', 404

        You can also register handlers for arbitrary exceptions::

            @app.errorhandler(DatabaseError)
            def special_exception_handler(error):
                return 'Database connection failed', 500

        You can also register a function as error handler without using
        the :meth:`errorhandler` decorator.  The following example is
        equivalent to the one above::

            def page_not_found(error):
                return 'This page does not exist', 404
            app.error_handler_spec[None][404] = page_not_found

        Setting error handlers via assignments to :attr:`error_handler_spec`
        however is discouraged as it requires fiddling with nested dictionaries
        and the special case for arbitrary exception types.

        The first `None` refers to the active blueprint.  If the error
        handler should be application wide `None` shall be used.

        .. versionadded:: 0.7
           One can now additionally also register custom exception types
           that do not necessarily have to be a subclass of the
           :class:`~werkzeug.exceptions.HTTPException` class.

        :param code: the code as integer for the handler
        c            s     j  d   |   |  S(   N(   t   _register_error_handlerRd   (   R7   (   R4   t   code_or_exception(    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyR   .  s    (    (   R4   R   R   (    (   R4   R   sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyt   errorhandler	  s    %c         C   s   |  j  d | |  d S(   s   Alternative error attach function to the :meth:`errorhandler`
        decorator that is more straightforward to use for non decorator
        usage.

        .. versionadded:: 0.7
        N(   R   Rd   (   R4   R   R7   (    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyt   register_error_handler3  s    c         C   s   t  | t  r | j } n  t  | t  rj | d k sN | d  k sN t d   | |  j j | i   | <n. |  j j | i   j d  g   j | | f  d  S(   Ni  s^   It is currently not possible to register a 500 internal server error on a per-blueprint level.(	   R.   R	   t   codeR,   Rd   R3   Rt   R   t   append(   R4   t   keyR   R7   (    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyR   <  s    	!c            s      f d   } | S(   s  A decorator that is used to register custom template filter.
        You can specify a name for the filter, otherwise the function
        name will be used. Example::

          @app.template_filter()
          def reverse(s):
              return s[::-1]

        :param name: the optional name of the filter, otherwise the
                     function name will be used.
        c            s     j  |  d  |  S(   NR   (   t   add_template_filter(   R7   (   R4   R   (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyR   V  s    (    (   R4   R   R   (    (   R4   R   sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyt   template_filterI  s    c         C   s   | |  j  j | p | j <d S(   s   Register a custom template filter.  Works exactly like the
        :meth:`template_filter` decorator.

        :param name: the optional name of the filter, otherwise the
                     function name will be used.
        N(   R   R   t   __name__(   R4   R7   R   (    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyR   [  s    c            s      f d   } | S(   sS  A decorator that is used to register custom template test.
        You can specify a name for the test, otherwise the function
        name will be used. Example::

          @app.template_test()
          def is_prime(n):
              if n == 2:
                  return True
              for i in range(2, int(math.ceil(math.sqrt(n))) + 1):
                  if n % i == 0:
                      return False
              return True

        .. 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_template_test(   R7   (   R4   R   (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyR   y  s    (    (   R4   R   R   (    (   R4   R   sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyt   template_teste  s    c         C   s   | |  j  j | p | j <d S(   s   Register a custom template test.  Works exactly like the
        :meth:`template_test` decorator.

        .. versionadded:: 0.10

        :param name: the optional name of the test, otherwise the
                     function name will be used.
        N(   R   t   testsR   (   R4   R7   R   (    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyR   ~  s    
c            s      f d   } | S(   s  A decorator that is used to register a custom template global function.
        You can specify a name for the global function, otherwise the function
        name will be used. Example::

            @app.template_global()
            def double(n):
                return 2 * n

        .. versionadded:: 0.10

        :param name: the optional name of the global function, otherwise the
                     function name will be used.
        c            s     j  |  d  |  S(   NR   (   t   add_template_global(   R7   (   R4   R   (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyR     s    (    (   R4   R   R   (    (   R4   R   sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyt   template_global  s    c         C   s   | |  j  j | p | j <d S(   s  Register a custom template global function. Works exactly like the
        :meth:`template_global` decorator.

        .. versionadded:: 0.10

        :param name: the optional name of the global function, otherwise the
                     function name will be used.
        N(   R   R   R   (   R4   R7   R   (    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyR     s    
c         C   s    |  j  j d g   j |  | S(   s0   Registers a function to run before each request.N(   Rv   R   Rd   R   (   R4   R7   (    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyt   before_request  s    c         C   s   |  j  j |  d S(   s   Registers a function to be run before the first request to this
        instance of the application.

        .. versionadded:: 0.8
        N(   Rw   R   (   R4   R7   (    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyt   before_first_request  s    c         C   s    |  j  j d g   j |  | S(   sg  Register a function to be run after each request.  Your function
        must take one parameter, a :attr:`response_class` object and return
        a new response object or the same (see :meth:`process_response`).

        As of Flask 0.7 this function might not be executed at the end of the
        request in case an unhandled exception occurred.
        N(   Rx   R   Rd   R   (   R4   R7   (    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyt   after_request  s    	c         C   s    |  j  j d g   j |  | S(   sR  Register a function to be run at the end of each request,
        regardless of whether there was an exception or not.  These functions
        are executed when the request context is popped, even if not an
        actual request was performed.

        Example::

            ctx = app.test_request_context()
            ctx.push()
            ...
            ctx.pop()

        When ``ctx.pop()`` is executed in the above example, the teardown
        functions are called just before the request context moves from the
        stack of active contexts.  This becomes relevant if you are using
        such constructs in tests.

        Generally teardown functions must take every necessary step to avoid
        that they will fail.  If they do execute code that might fail they
        will have to surround the execution of these code by try/except
        statements and log occurring errors.

        When a teardown function was called because of a exception it will
        be passed an error object.

        .. admonition:: Debug Note

           In debug mode Flask will not tear down a request on an exception
           immediately.  Instead if will keep it alive so that the interactive
           debugger can still access it.  This behavior can be controlled
           by the ``PRESERVE_CONTEXT_ON_EXCEPTION`` configuration variable.
        N(   Ry   R   Rd   R   (   R4   R7   (    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyt   teardown_request  s    "c         C   s   |  j  j |  | S(   s>  Registers a function to be called when the application context
        ends.  These functions are typically also called when the request
        context is popped.

        Example::

            ctx = app.app_context()
            ctx.push()
            ...
            ctx.pop()

        When ``ctx.pop()`` is executed in the above example, the teardown
        functions are called just before the app context moves from the
        stack of active contexts.  This becomes relevant if you are using
        such constructs in tests.

        Since a request context typically also manages an application
        context it would also be called when you pop a request context.

        When a teardown function was called because of an exception it will
        be passed an error object.

        .. versionadded:: 0.9
        (   Rz   R   (   R4   R7   (    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyt   teardown_appcontext  s    c         C   s   |  j  d j |  | S(   s0   Registers a template context processor function.N(   R}   Rd   R   (   R4   R7   (    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyt   context_processor  s    c         C   s    |  j  j d g   j |  | S(   s   Registers a function as URL value preprocessor for all view
        functions of the application.  It's called before the view functions
        are called and can modify the url values provided.
        N(   R{   R   Rd   R   (   R4   R7   (    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyt   url_value_preprocessor  s    c         C   s    |  j  j d g   j |  | S(   s   Callback function for URL defaults for all view functions of the
        application.  It's called with the endpoint and values and should
        update the values passed in place.
        N(   R|   R   Rd   R   (   R4   R7   (    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyt   url_defaults  s    c         C   s   |  j  j t j  } | j d k r( | S| rM | j | k rM | | j } n |  j  d j | j  } | d k rv | S| |  S(   s   Handles an HTTP exception.  By default this will invoke the
        registered error handlers and fall back to returning the
        exception as response.

        .. versionadded:: 0.3
        N(   Rt   R   R   R   R   Rd   (   R4   t   et   handlerst   handler(    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyt   handle_http_exception   s    c         C   s/   |  j  d r t S|  j  d r+ t | t  St S(   s  Checks if an HTTP exception should be trapped or not.  By default
        this will return `False` for all exceptions except for a bad request
        key error if ``TRAP_BAD_REQUEST_ERRORS`` is set to `True`.  It
        also returns `True` if ``TRAP_HTTP_EXCEPTIONS`` is set to `True`.

        This is called for all HTTP exceptions raised by a view function.
        If it returns `True` for any exception the error handler for this
        exception is not called and it shows up as regular exception in the
        traceback.  This is helpful for debugging implicitly raised HTTP
        exceptions.

        .. versionadded:: 0.8
        RW   RV   (   Rn   R   R.   R   R   (   R4   R	  (    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyt   trap_http_exception4  s
    c   
      C   s   t  j   \ } } } | | k s' t  t | t  rS |  j |  rS |  j |  Sd } |  j j t	 j
  } | d k	 r | j d d  } n  |  j d j d d  } x6 t | |  D]% \ } }	 t | |  r |	 |  Sq Wt | | |  d S(   s  This method is called whenever an exception occurs that should be
        handled.  A special case are
        :class:`~werkzeug.exception.HTTPException`\s which are forwarded by
        this function to the :meth:`handle_http_exception` method.  This
        function will either return a response value or reraise the
        exception with the same traceback.

        .. versionadded:: 0.7
        N(    (    (    (   R   t   exc_infoR3   R.   R	   R  R  Rt   R   R   R   Rd   R   R)   (
   R4   R	  t   exc_typet	   exc_valuet   tbt   blueprint_handlersR
  t   app_handlerst	   typecheckR  (    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyt   handle_user_exceptionH  s    
c         C   s   t  j   \ } } } t j |  d | |  j d j d  } |  j ro | | k rf t | | |  qo |  n  |  j	 | | | f  | d k r t
   S| |  S(   s  Default exception handling that kicks in when an exception
        occurs that is not caught.  In debug mode the exception will
        be re-raised immediately, otherwise it is logged and the handler
        for a 500 internal server error is used.  If no such handler
        exists, a default 500 internal server error message is displayed.

        .. versionadded:: 0.3
        t	   exceptioni  N(   R   R  R&   t   sendRt   Rd   R   R   R)   t   log_exceptionR
   (   R4   R	  R  R  R  R  (    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyt   handle_exceptiong  s    			c         C   s*   |  j  j d t j t j f d | d S(   s  Logs an exception.  This is called by :meth:`handle_exception`
        if debugging is disabled and right before the handler is called.
        The default implementation logs the exception as error on the
        :attr:`logger`.

        .. versionadded:: 0.8
        s   Exception on %s [%s]R  N(   R   t   errorR   Ri   t   method(   R4   R  (    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyR    s    c         C   sX   |  j  s, t | j t  s, | j d k r8 | j  n  d d l m } | |   d S(   s.  Exceptions that are recording during routing are reraised with
        this method.  During debug we are not reraising redirect requests
        for non ``GET``, ``HEAD``, or ``OPTIONS`` requests and we're raising
        a different error instead to help debug situations.

        :internal:
        R   t   HEADR   i   (   t   FormDataRoutingRedirectN(   s   GETR  s   OPTIONS(   R1   R.   t   routing_exceptionR   R  t   debughelpersR  (   R4   R   R  (    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyt   raise_routing_exception  s    
c         C   sv   t  j j } | j d k	 r+ |  j |  n  | j } t | d t  r_ | j	 d k r_ |  j
   S|  j | j | j   S(   s  Does the request dispatching.  Matches the URL and returns the
        return value of the view or error handler.  This does not have to
        be a response object.  In order to convert the return value to a
        proper response object, call :func:`make_response`.

        .. versionchanged:: 0.7
           This no longer does the exception handling, this code was
           moved to the new :meth:`full_dispatch_request`.
        R   R   N(   R   R   R   R  Rd   R   t   url_ruleR   R   R  t   make_default_options_responseRr   Ra   t	   view_args(   R4   t   reqR   (    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyt   dispatch_request  s    
	
c         C   s   |  j    y8 t j |   |  j   } | d k rA |  j   } n  Wn" t k
 rf } |  j |  } n X|  j |  } |  j	 |  } t
 j |  d | | S(   s   Dispatches the request and on top of that performs request
        pre and postprocessing as well as HTTP exception catching and
        error handling.

        .. versionadded:: 0.7
        R   N(   t*   try_trigger_before_first_request_functionsR$   R  t   preprocess_requestRd   R%  t	   ExceptionR  t   make_responset   process_responseR%   (   R4   R   R	  R   (    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyt   full_dispatch_request  s    
c         C   sR   |  j  r d S|  j 6 |  j  r$ d St |  _  x |  j D] } |   q7 WWd QXd S(   s   Called before each request and will ensure that it triggers
        the :attr:`before_first_request_funcs` and only exactly once per
        application instance (which means process usually).

        :internal:
        N(   R2   R   R   Rw   (   R4   R   (    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyR&    s    	
		c         C   s   t  j j } t | d  r* | j   } nK g  } y | j d d  Wn. t k
 rb } | j } n t k
 rt } n X|  j	   } | j
 j |  | S(   s   This method is called to create the default `OPTIONS` response.
        This can be changed through subclassing to change the default
        behavior of `OPTIONS` responses.

        .. versionadded:: 0.7
        t   allowed_methodsR  s   --(   R   R   t   url_adaptert   hasattrR,  t   matchR   t   valid_methodsR	   R   t   allowR   (   R4   t   adapterR   R	  R   (    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyR"    s    c         C   s   t  S(   s  This is called to figure out if an error should be ignored
        or not as far as the teardown system is concerned.  If this
        function returns `True` then the teardown handlers will not be
        passed the error.

        .. versionadded:: 0.10
        (   R   (   R4   R  (    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyt   should_ignore_error  s    c         C   s  d } } t | t  r= | d d t |  \ } } } n  | d k rX t d   n  t | |  j  s t | t t t f  r |  j | d | d | } d } } q |  j j	 | t
 j  } n  | d k	 r t | t  r | | _ q | | _ n  | r| j j |  n  | S(   sr  Converts the return value from a view function to a real
        response object that is an instance of :attr:`response_class`.

        The following types are allowed for `rv`:

        .. tabularcolumns:: |p{3.5cm}|p{9.5cm}|

        ======================= ===========================================
        :attr:`response_class`  the object is returned unchanged
        :class:`str`            a response object is created with the
                                string as body
        :class:`unicode`        a response object is created with the
                                string encoded to utf-8 as body
        a WSGI function         the function is called as WSGI application
                                and buffered as response object
        :class:`tuple`          A tuple in the form ``(response, status,
                                headers)`` where `response` is any of the
                                types defined here, `status` is a string
                                or an integer and `headers` is a list of
                                a dictionary with header values.
        ======================= ===========================================

        :param rv: the return value from the view function

        .. versionchanged:: 0.9
           Previously a tuple was interpreted as the arguments for the
           response object.
        i   s'   View function did not return a responset   headerst   statusN(   N(   Rd   R.   t   tuplet   lenRk   R   R+   t   bytest	   bytearrayt
   force_typeR   t   environR*   R5  t   status_codeR4  t   extend(   R4   R   R5  R4  (    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyR)    s"    
$c         C   sz   | d k	 r, |  j j | j d |  j d S|  j d d k	 rv |  j j |  j d d |  j d pe d d |  j d Sd S(	   s  Creates a URL adapter for the given request.  The URL adapter
        is created at a point where the request context is not yet set up
        so the request is passed explicitly.

        .. versionadded:: 0.6

        .. versionchanged:: 0.9
           This can now also be called without a request object when the
           URL adapter is created for the application context.
        R   RN   t   script_nameRO   t   /t
   url_schemeRY   N(   Rd   R   t   bind_to_environR;  Rn   t   bind(   R4   R   (    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyt   create_url_adapter5  s    	c         C   sz   |  j  j d d  } d | k rX | j d d  d } t | |  j  j | d   } n  x | D] } | | |  q_ Wd S(   s   Injects the URL defaults for the given endpoint directly into
        the values dictionary passed.  This is used internally and
        automatically called on URL building.

        .. versionadded:: 0.7
        t   .i   i    N(    (    (   R|   R   Rd   R   R   (   R4   Ra   t   valuesR   R   R   (    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyt   inject_url_defaultsK  s    !c   	      C   s   t  j   \ } } } xM |  j D]B } y& | | | |  } | d k	 rJ | SWq t k
 r` } q Xq W| | k r t | | |  n  |  d S(   sI   Handle :class:`~werkzeug.routing.BuildError` on :meth:`url_for`.
        N(   R   R  Ru   Rd   R   R)   (	   R4   R  Ra   RE  R  R  R  R  R   (    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyt   handle_url_build_errorY  s    c         C   s   t  j j j } |  j j d d  } | d k	 rX | |  j k rX t | |  j |  } n  x! | D] } | t j t j	  q_ W|  j
 j d d  } | d k	 r | |  j
 k r t | |  j
 |  } n  x' | D] } |   } | d k	 r | Sq Wd S(   s  Called before the actual request dispatching and will
        call every as :meth:`before_request` decorated function.
        If any of these function returns a value it's handled as
        if it was the return value from the view and further
        request handling is stopped.

        This also triggers the :meth:`url_value_processor` functions before
        the actual :meth:`before_request` functions are called.
        N(    (    (   R   R   R   R   R{   R   Rd   R   Ra   R#  Rv   (   R4   R   R   R   R   (    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyR'  l  s    
	c         C   s   t  j } | j j } | j } | d k	 rX | |  j k rX t | t |  j |   } n  d |  j k r t | t |  j d   } n  x | D] } | |  } q W|  j	 j
 | j  s |  j | j |  n  | S(   s  Can be overridden in order to modify the response object
        before it's sent to the WSGI server.  By default this will
        call all the :meth:`after_request` decorated functions.

        .. versionchanged:: 0.5
           As of Flask 0.5 the functions registered for after request
           execution are called in reverse order of registration.

        :param response: a :attr:`response_class` object.
        :return: a new response object or the same, has to be an
                 instance of :attr:`response_class`.
        N(   R   R   R   R   t   _after_request_functionsRd   Rx   R   t   reversedR   t   is_null_sessionR   R   (   R4   R   t   ctxR   R   R  (    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyR*    s    		c         C   s   | d k r t j   d } n  t |  j j d d   } t j j j	 } | d k	 r | |  j k r t
 | t |  j |   } n  x | D] } | |  } q Wt j |  d | d S(   s  Called after the actual request dispatching and will
        call every as :meth:`teardown_request` decorated function.  This is
        not actually called by the :class:`Flask` object itself but is always
        triggered when the request context is popped.  That way we have a
        tighter control over certain resources under testing environments.

        .. versionchanged:: 0.9
           Added the `exc` argument.  Previously this was always using the
           current exception information.
        i   t   excN(    (   Rd   R   R  RI  Ry   R   R   R   R   R   R   R'   R  (   R4   RL  R   R   R   R   (    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyt   do_teardown_request  s    c         C   sZ   | d k r t j   d } n  x! t |  j  D] } | |  q/ Wt j |  d | d S(   s   Called when an application context is popped.  This works pretty
        much the same as :meth:`do_teardown_request` but for the application
        context.

        .. versionadded:: 0.9
        i   RL  N(   Rd   R   R  RI  Rz   R(   R  (   R4   RL  R   (    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyt   do_teardown_appcontext  s
    c         C   s
   t  |   S(   s  Binds the application only.  For as long as the application is bound
        to the current context the :data:`flask.current_app` points to that
        application.  An application context is automatically created when a
        request context is pushed if necessary.

        Example usage::

            with app.app_context():
                ...

        .. versionadded:: 0.9
        (   R   (   R4   (    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyt   app_context  s    c         C   s   t  |  |  S(   s  Creates a :class:`~flask.ctx.RequestContext` from the given
        environment and binds it to the current context.  This must be used in
        combination with the `with` statement because the request is only bound
        to the current context for the duration of the `with` block.

        Example usage::

            with app.request_context(environ):
                do_something_with(request)

        The object returned can also be used without the `with` statement
        which is useful for working in the shell.  The example above is
        doing exactly the same as this code::

            ctx = app.request_context(environ)
            ctx.push()
            try:
                do_something_with(request)
            finally:
                ctx.pop()

        .. versionchanged:: 0.3
           Added support for non-with statement usage and `with` statement
           is now passed the ctx object.

        :param environ: a WSGI environment
        (   R   (   R4   R;  (    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyt   request_context  s    c         O   sK   d d l  m } | |  | |  } z |  j | j    SWd | j   Xd S(   s   Creates a WSGI environment from the given values (see
        :func:`werkzeug.test.EnvironBuilder` for more information, this
        function accepts the same arguments).
        i(   t   make_test_environ_builderN(   R   RQ  RP  t   get_environt   close(   R4   R5   R6   RQ  t   builder(    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyt   test_request_context  s
    c         C   s   |  j  |  } | j   d } zU y |  j   } Wn1 t k
 re } | } |  j |  j |   } n X| | |  SWd |  j |  r d } n  | j |  Xd S(   s  The actual WSGI application.  This is not implemented in
        `__call__` so that middlewares can be applied without losing a
        reference to the class.  So instead of doing this::

            app = MyMiddleware(app)

        It's a better idea to do this instead::

            app.wsgi_app = MyMiddleware(app.wsgi_app)

        Then you still have the original application object around and
        can continue to call methods on it.

        .. versionchanged:: 0.7
           The behavior of the before and after request callbacks was changed
           under error conditions and a new callback was added that will
           always execute at the end of the request, independent on if an
           error occurred or not.  See :ref:`callbacks-and-errors`.

        :param environ: a WSGI environment
        :param start_response: a callable accepting a status code,
                               a list of headers and an optional
                               exception context to start the response
        N(	   RP  t   pushRd   R+  R(  R)  R  R3  t   auto_pop(   R4   R;  t   start_responseRK  R  R   R	  (    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyt   wsgi_app  s    
	c         C   s-   d d l  m } | t d  d d |  j S(   Ni(   R=   s9   Flask.modules is deprecated, use Flask.blueprints insteadR`   i   (   R>   R=   R?   R~   (   R4   R=   (    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyR   #  s    c         C   s   |  j  | |  S(   s   Shortcut for :attr:`wsgi_app`.(   RY  (   R4   R;  RX  (    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyt   __call__*  s    c         C   s   d |  j  j |  j f S(   Ns   <%s %r>(   t	   __class__R   R   (   R4   (    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyt   __repr__.  s    	Ni  i  (r   R   t
   __module__t   __doc__R   t   request_classR   R   R   R;   R<   R@   t   propertyt   request_globals_classR   R1   R   t
   secret_keyt   session_cookie_nameR0   t   permanent_session_lifetimet   use_x_sendfileRq   R   R   t   debug_log_formatR   t   JSONEncodert   json_encodert   JSONDecodert   json_decoderR   R   R   Rd   R   R   R   R   R   R   R   Rc   R   R   t   error_handlersR   R   R   R   R   R   R   Rm   Rg   R   R   R   R   R   R   R   R   R   R   R   R   R9   R   R   R   Ra   R   R   R   R   R   R   R   R   R   R  R  R  R  R  R  R  R  R  R  R  R  R  R   R%  R+  R&  R"  R3  R)  RC  RF  RG  R'  R*  RM  RN  RO  RP  RU  RY  R   RZ  R\  (    (    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyR:   B   s  J							

												
	9&	
			_	*				%													
	9									(	(F   R^  Rh   R   t	   threadingR    t   datetimeR   t	   itertoolsR   t	   functoolsR   t   werkzeug.datastructuresR   t   werkzeug.routingR   R   R   R   t   werkzeug.exceptionsR	   R
   R   R   t   helpersR   R   R   R   R   R   t    R   t   wrappersR   R   Rn   R   R   RK  R   R   R   R   R   R   R   R   t   sessionsR   R   R    t
   templatingR!   R"   R#   t   signalsR$   R%   R&   R'   R(   t   _compatR)   R*   R+   R,   R   R0   R9   R:   (    (    (    sO   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/app.pyt   <module>
   s0   ""."("			