/usr/local/lib64/python3.6/site-packages/flask/__pycache__
NameSizeModeActions
app.cpython-36.pyc628380644editdlrm
blueprints.cpython-36.pyc218950644editdlrm
cli.cpython-36.pyc268820644editdlrm
config.cpython-36.pyc115620644editdlrm
ctx.cpython-36.pyc154410644editdlrm
debughelpers.cpython-36.pyc63770644editdlrm
globals.cpython-36.pyc17420644editdlrm
helpers.cpython-36.pyc270040644editdlrm
logging.cpython-36.pyc24000644editdlrm
scaffold.cpython-36.pyc247450644editdlrm
sessions.cpython-36.pyc135440644editdlrm
signals.cpython-36.pyc23320644editdlrm
templating.cpython-36.pyc54490644editdlrm
testing.cpython-36.pyc90890644editdlrm
typing.cpython-36.pyc13630644editdlrm
views.cpython-36.pyc49100644editdlrm
wrappers.cpython-36.pyc49010644editdlrm
__init__.cpython-36.pyc18390644editdlrm
__main__.cpython-36.pyc1700644editdlrm
Edit: /usr/local/lib64/python3.6/site-packages/flask/__pycache__/ctx.cpython-36.pyc (15441B)
3 ^TBgD@sddlZddlZddlmZddlmZddlmZddl m Z ddl m Z ddl m Z dd l mZdd lmZejrdd lmZdd lmZdd lmZeZGdddZeedddZejejdddZedddZedddZGdddZ GdddZ!dS)N)update_wrapper) TracebackType) HTTPException)_app_ctx_stack)_request_ctx_stack)appcontext_popped)appcontext_pushed)AfterRequestCallable)Flask) SessionMixin)Requestc@seZdZdZeejdddZeejddddZeddd d Z deej ejejd d d Z e feejejd ddZ deejejd ddZeedddZejedddZedddZdS)_AppCtxGlobalsaA plain object. Used as a namespace for storing data during an application context. Creating an app context automatically creates this object, which is made available as the :data:`g` proxy. .. describe:: 'key' in g Check whether an attribute is present. .. versionadded:: 0.10 .. describe:: iter(g) Return an iterator over the attribute names. .. versionadded:: 0.10 )namereturnc Cs.y |j|Stk r(t|dYnXdS)N)__dict__KeyErrorAttributeError)selfrr*/tmp/pip-build-0s3hx122/flask/flask/ctx.py __getattr__/s z_AppCtxGlobals.__getattr__N)rvaluercCs||j|<dS)N)r)rrrrrr __setattr__5sz_AppCtxGlobals.__setattr__c Cs0y |j|=Wntk r*t|dYnXdS)N)rrr)rrrrr __delattr__8s z_AppCtxGlobals.__delattr__)rdefaultrcCs|jj||S)zGet an attribute by name, or a default value. Like :meth:`dict.get`. :param name: Name of attribute to get. :param default: Value to return if the attribute is not present. .. versionadded:: 0.10 )rget)rrrrrrr>s z_AppCtxGlobals.getcCs&|tkr|jj|S|jj||SdS)a Get and remove an attribute by name. Like :meth:`dict.pop`. :param name: Name of attribute to pop. :param default: Value to return if the attribute is not present, instead of raising a ``KeyError``. .. versionadded:: 0.11 N) _sentinelrpop)rrrrrrrIs  z_AppCtxGlobals.popcCs|jj||S)a5Get the value of an attribute if it is present, otherwise set and return a default value. Like :meth:`dict.setdefault`. :param name: Name of attribute to get. :param default: Value to set and return if the attribute is not present. .. versionadded:: 0.11 )r setdefault)rrrrrrrWs z_AppCtxGlobals.setdefault)itemrcCs ||jkS)N)r)rr rrr __contains__csz_AppCtxGlobals.__contains__)rcCs t|jS)N)iterr)rrrr__iter__fsz_AppCtxGlobals.__iter__cCs(tj}|dk rd|jjdStj|S)Nz )rtopapprobject__repr__)rr%rrrr(isz_AppCtxGlobals.__repr__)N)N)__name__ __module__ __qualname____doc__strtZAnyrrrOptionalrrrrboolr!Iteratorr#r(rrrrrs  r)frcCs&tj}|dkrtd|jj||S)aExecutes a function after this request. This is useful to modify response objects. The function is passed the response object and has to return the same or a new one. Example:: @app.route('/') def index(): @after_this_request def add_header(response): response.headers['X-Foo'] = 'Parachute' return response return 'Hello World!' This is more useful if a function other than the view function wants to modify a response. For instance think of a decorator that wants to add some headers without converting the return value into a response object. .. versionadded:: 0.9 NzaThis decorator can only be used when a request context is active, such as within a view function.)rr% RuntimeError_after_request_functionsappend)r2r%rrrafter_this_requestps  r6cs6tj}|dkrtd|jfdd}t|S)a:A helper function that decorates a function to retain the current request context. This is useful when working with greenlets. The moment the function is decorated a copy of the request context is created and then pushed when the function is called. The current session is also included in the copied request context. Example:: import gevent from flask import copy_current_request_context @app.route('/') def index(): @copy_current_request_context def do_some_work(): # do some work here, it can access flask.request or # flask.session like you would otherwise in the view function. ... gevent.spawn(do_some_work) return 'Regular response' .. versionadded:: 0.10 NzaThis decorator can only be used when a request context is active, such as within a view function.c s ||SQRXdS)Nr)argskwargs)r2reqctxrrwrappersz-copy_current_request_context..wrapper)rr%r3copyr)r2r%r:r)r2r9rcopy_current_request_contextsr<)rcCs tjdk S)aIf you have code that wants to test if a request context is there or not this function can be used. For instance, you may want to take advantage of request information if the request object is available, but fail silently if it is unavailable. :: class User(db.Model): def __init__(self, username, remote_addr=None): self.username = username if remote_addr is None and has_request_context(): remote_addr = request.remote_addr self.remote_addr = remote_addr Alternatively you can also just test any of the context bound objects (such as :class:`request` or :class:`g`) for truthness:: class User(db.Model): def __init__(self, username, remote_addr=None): self.username = username if remote_addr is None and request: remote_addr = request.remote_addr self.remote_addr = remote_addr .. versionadded:: 0.7 N)rr%rrrrhas_request_contextsr=cCs tjdk S)zWorks like :func:`has_request_context` but for the application context. You can also just do a boolean check on the :data:`current_app` object instead. .. versionadded:: 0.9 N)rr%rrrrhas_app_contextsr>c@sjeZdZdZdddddZdddd Zefeje dd d d Z ddd dZ e e e ddddZdS) AppContexta]The application context binds an application object implicitly to the current thread or greenlet, similar to how the :class:`RequestContext` binds request information. The application context is also implicitly created if a request context is created but the application is not on top of the individual application context. r N)r&rcCs&||_|jd|_|j|_d|_dS)Nr)r&create_url_adapter url_adapterZapp_ctx_globals_classg_refcnt)rr&rrr__init__s  zAppContext.__init__)rcCs(|jd7_tj|tj|jdS)z-Binds the app context to the current context.rN)rCrpushr sendr&)rrrrrEs zAppContext.push)excrcCsvz<|jd8_|jdkr:|tkr.tjd}|jj|Wdtj}X||ksftd|d|dt j |jdS)zPops the app context.rrNzPopped wrong app context. (z instead of )) rCrsysexc_infor&Zdo_teardown_appcontextrrAssertionErrorrrF)rrGrvrrrrs   zAppContext.popcCs |j|S)N)rE)rrrr __enter__ szAppContext.__enter__)exc_type exc_valuetbrcCs|j|dS)N)r)rrNrOrPrrr__exit__ szAppContext.__exit__)r)r*r+r,rDrErr.r/ BaseExceptionrrMtyperrQrrrrr?s  r?c@seZdZdZd deejdejdddddZee d d d Z e j e dd d d Z dd ddZ dd ddZ dd ddZefejeddddZejeddddZdd ddZeeeddddZed ddZdS)!RequestContextaThe request context contains all request relevant information. It is created at the beginning of the request and pushed to the `_request_ctx_stack` and removed at the end of it. It will create the URL adapter and request object for the WSGI environment provided. Do not attempt to use this class directly, instead use :meth:`~flask.Flask.test_request_context` and :meth:`~flask.Flask.request_context` to create this object. When the request context is popped, it will evaluate all the functions registered on the application for teardown execution (:meth:`~flask.Flask.teardown_request`). The request context is automatically popped at the end of the request for you. In debug mode the request context is kept around if exceptions happen so that interactive debuggers have a chance to introspect the data. With 0.4 this can also be forced for requests that did not fail and outside of ``DEBUG`` mode. By setting ``'flask._preserve_context'`` to ``True`` on the WSGI environment the context will not pop itself at the end of the request. This is used by the :meth:`~flask.Flask.test_client` for example to implement the deferred cleanup functionality. You might find this helpful for unittests where you need the information from the context local around for a little longer. Make sure to properly :meth:`~werkzeug.LocalStack.pop` the stack yourself in that situation, otherwise your unittests will leak memory. Nr r r )r&environrequestsessionrcCs||_|dkr|j|}||_d|_y|j|j|_Wn*tk r`}z||j_WYdd}~XnXd|_||_g|_ d|_ d|_ g|_ dS)NF) r&Z request_classrVrAr@rrouting_exceptionZflashesrW_implicit_app_ctx_stack preserved_preserved_excr4)rr&rUrVrWerrrrD1s zRequestContext.__init__)rcCstjjS)N)rr%rB)rrrrrBWszRequestContext.g)rrcCs |tj_dS)N)rr%rB)rrrrrrB[scCs|j|j|jj|j|jdS)a5Creates a copy of this request context with the same request object. This can be used to move a request context to a different greenlet. Because the actual request object is the same this cannot be used to move a request context to a different thread unless access to the request object is locked. .. versionadded:: 0.10 .. versionchanged:: 1.1 The current session object is used instead of reloading the original data. This prevents `flask.session` pointing to an out-of-date object. )rUrVrW) __class__r&rVrUrW)rrrrr;_s zRequestContext.copycCsRy"|jjdd}|\|j_|j_Wn*tk rL}z||j_WYdd}~XnXdS)zZCan be overridden by a subclass to hook into the matching of the request. T)Z return_ruleN)rAmatchrVZurl_ruleZ view_argsrrX)rresultr\rrr match_requestss zRequestContext.match_requestcCstj}|dk r |jr |j|jtj}|dks:|j|jkrZ|jj}|j|j j |n |j j dtj||j dkr|jj }|j |j|j|_ |j dkr|j|j|_ |jdk r|jdS)z1Binds the request context to the current context.N)rr%rZrr[rr&Z app_contextrErYr5rWsession_interfaceZ open_sessionrVZmake_null_sessionrAr`)rr%app_ctxrarrrrE}s"        zRequestContext.push)rGrcCs|jj}d}zV|jsbd|_d|_|tkr6tjd}|jj|t |j dd}|dk r^|d}Wdt j}|r~d|j j d<|dk r|j|||kst d|d|d XdS) a Pops the request context and unbinds it by doing that. This will also trigger the execution of functions registered by the :meth:`~flask.Flask.teardown_request` decorator. .. versionchanged:: 0.9 Added the `exc` argument. FNrcloseTzwerkzeug.requestzPopped wrong request context. (z instead of rH)rYrrZr[rrIrJr&Zdo_teardown_requestgetattrrVrrUrK)rrGrbZ clear_requestZ request_closerLrrrrs(      zRequestContext.popcCs:|jjjds|dk r,|jjr,d|_||_n |j|dS)Nzflask._preserve_contextT)rVrUrr&Zpreserve_context_on_exceptionrZr[r)rrGrrrauto_pops zRequestContext.auto_popcCs |j|S)N)rE)rrrrrMszRequestContext.__enter__)rNrOrPrcCs|j|dS)N)re)rrNrOrPrrrrQszRequestContext.__exit__c Cs0dt|jd|jjd|jjd|jjd S)N< z [z] of r$)rSr)rVurlmethodr&r)rrrrr(szRequestContext.__repr__)NN)r)r*r+r,dictr.r/rDpropertyr?rBsetterr;r`rErrRrrerMrSrrQr-r(rrrrrTs"  *' rT)"rIZtypingr. functoolsrtypesrZwerkzeug.exceptionsrglobalsrrZsignalsrr r Z TYPE_CHECKINGr&r sessionsr Zwrappersr r'rrr6Callabler<r0r=r>r?rTrrrrs*           X!)  /