https://t.me/AnonymousX5
Server : Apache
System : Linux cvar2.toservers.com 3.10.0-962.3.2.lve1.5.73.el7.x86_64 #1 SMP Wed Aug 24 21:31:23 UTC 2022 x86_64
User : njnconst ( 1116)
PHP Version : 8.4.18
Disable Function : NONE
Directory :  /lib64/python2.7/site-packages/flask/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib64/python2.7/site-packages/flask/ctx.pyc
�
-/�_c@sdZddlZddlmZddlmZddlmZddlmZddl	m
Z
dd	l	mZdd
lm
Z
ddlmZe�Zdefd
��YZd�Zd�Zd�Zd�Zdefd��YZdefd��YZdS(s�
    flask.ctx
    ~~~~~~~~~

    Implements the objects required to keep the context.

    :copyright: 2010 Pallets
    :license: BSD-3-Clause
i����N(tupdate_wrapper(t
HTTPExceptioni(tBROKEN_PYPY_CTXMGR_EXIT(treraise(t_app_ctx_stack(t_request_ctx_stack(tappcontext_popped(tappcontext_pushedt_AppCtxGlobalscBsMeZdZdd�Zed�Zdd�Zd�Zd�Z	d�Z
RS(s�A 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
    cCs|jj||�S(s�Get 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
        (t__dict__tget(tselftnametdefault((s*/tmp/pip-install-sTXtzD/flask/flask/ctx.pyR
0s	cCs3|tkr|jj|�S|jj||�SdS(s
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 raise a ``KeyError``.

        .. versionadded:: 0.11
        N(t	_sentinelR	tpop(RRR
((s*/tmp/pip-install-sTXtzD/flask/flask/ctx.pyR;s	cCs|jj||�S(s6Get 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	t
setdefault(RRR
((s*/tmp/pip-install-sTXtzD/flask/flask/ctx.pyRIs
cCs
||jkS(N(R	(Rtitem((s*/tmp/pip-install-sTXtzD/flask/flask/ctx.pyt__contains__UscCs
t|j�S(N(titerR	(R((s*/tmp/pip-install-sTXtzD/flask/flask/ctx.pyt__iter__XscCs0tj}|dk	r#d|jjStj|�S(Ns<flask.g of %r>(RttoptNonetappRtobjectt__repr__(RR((s*/tmp/pip-install-sTXtzD/flask/flask/ctx.pyR[s	N(t__name__t
__module__t__doc__RR
RRRRRR(((s*/tmp/pip-install-sTXtzD/flask/flask/ctx.pyRs		cCstjjj|�|S(s�Executes 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
    (RRt_after_request_functionstappend(tf((s*/tmp/pip-install-sTXtzD/flask/flask/ctx.pytafter_this_requestbscsOtj}|dkr$td��n|j����fd�}t|��S(s: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
    s|This decorator can only be used at local scopes when a request context is on the stack.  For instance within view functions.cs���||�SWdQXdS(N((targstkwargs(Rtreqctx(s*/tmp/pip-install-sTXtzD/flask/flask/ctx.pytwrapper�sN(RRRtRuntimeErrortcopyR(RRR$((RR#s*/tmp/pip-install-sTXtzD/flask/flask/ctx.pytcopy_current_request_context{s	cCs
tjdk	S(s�If 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(RRR(((s*/tmp/pip-install-sTXtzD/flask/flask/ctx.pythas_request_context�scCs
tjdk	S(s�Works 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(RRR(((s*/tmp/pip-install-sTXtzD/flask/flask/ctx.pythas_app_context�st
AppContextcBs>eZdZd�Zd�Zed�Zd�Zd�ZRS(s]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.
    cCs7||_|jd�|_|j�|_d|_dS(Ni(Rtcreate_url_adapterRturl_adaptertapp_ctx_globals_classtgt_refcnt(RR((s*/tmp/pip-install-sTXtzD/flask/flask/ctx.pyt__init__�s	cCsL|jd7_ttd�r+tj�ntj|�tj|j�dS(s-Binds the app context to the current context.it	exc_clearN(	R/thasattrtsysR1RtpushRtsendR(R((s*/tmp/pip-install-sTXtzD/flask/flask/ctx.pyR4�s


cCs�zT|jd8_|jdkrS|tkr@tj�d}n|jj|�nWdtj�}X||ks�td||f��t	j
|j�dS(sPops the app context.iiNs-Popped wrong app context.  (%r instead of %r)(R/RR3texc_infoRtdo_teardown_appcontextRRtAssertionErrorRR5(Rtexctrv((s*/tmp/pip-install-sTXtzD/flask/flask/ctx.pyR�s
"cCs|j�|S(N(R4(R((s*/tmp/pip-install-sTXtzD/flask/flask/ctx.pyt	__enter__�s
cCs6|j|�tr2|dk	r2t|||�ndS(N(RRRR(Rtexc_typet	exc_valuettb((s*/tmp/pip-install-sTXtzD/flask/flask/ctx.pyt__exit__�s
(	RRRR0R4RRR;R?(((s*/tmp/pip-install-sTXtzD/flask/flask/ctx.pyR*�s			
	tRequestContextcBs�eZdZddd�Zed��Zejd��Zd�Zd�Z	d�Z
ed�Zd�Z
d	�Zd
�Zd�ZRS(
s�The 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.
    cCs�||_|dkr'|j|�}n||_d|_y|j|j�|_Wntk
rs}||j_nXd|_||_	g|_
t|_d|_
g|_dS(N(RRt
request_classtrequestR,R+Rtrouting_exceptiontflashestsessiont_implicit_app_ctx_stacktFalset	preservedt_preserved_excR(RRtenvironRBREte((s*/tmp/pip-install-sTXtzD/flask/flask/ctx.pyR0s								cCs
tjjS(N(RRR.(R((s*/tmp/pip-install-sTXtzD/flask/flask/ctx.pyR.=scCs|tj_dS(N(RRR.(Rtvalue((s*/tmp/pip-install-sTXtzD/flask/flask/ctx.pyR.AscCs.|j|jd|jjd|jd|j�S(s5Creates 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.
        RJRBRE(t	__class__RRBRJRE(R((s*/tmp/pip-install-sTXtzD/flask/flask/ctx.pyR&Es

		cCsWy1|jjdt�}|\|j_|j_Wntk
rR}||j_nXdS(sZCan be overridden by a subclass to hook into the matching
        of the request.
        treturn_ruleN(R,tmatchtTrueRBturl_rulet	view_argsRRC(RtresultRK((s*/tmp/pip-install-sTXtzD/flask/flask/ctx.pyt
match_requestYs
cCs=tj}|dk	r1|jr1|j|j�ntj}|dksX|j|jkr�|jj�}|j	�|j
j|�n|j
jd�tt
d�r�t
j�ntj	|�|jdkr|jj}|j|j|j�|_|jdkr|j|j�|_qn|jdk	r9|j�ndS(s1Binds the request context to the current context.R1N(RRRRHRRIRRtapp_contextR4RFRR2R3R1REtsession_interfacetopen_sessionRBtmake_null_sessionR,RT(RRtapp_ctxRV((s*/tmp/pip-install-sTXtzD/flask/flask/ctx.pyR4cs&
		


cCs|jj�}z�t}|js�t|_d|_|tkrRtj�d}n|j	j
|�ttd�r~tj�nt
|jdd�}|dk	r�|�nt}nWdtj�}|r�d|jjd<n|dk	r�|j|�n||kstd||f��XdS(sPops 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.
        iR1tcloseNswerkzeug.requests0Popped wrong request context. (%r instead of %r)(RFRRGRHRRIRR3R6Rtdo_teardown_requestR2R1tgetattrRBRPRRJR8(RR9RYt
clear_requestt
request_closeR:((s*/tmp/pip-install-sTXtzD/flask/flask/ctx.pyR�s.			


cCsS|jjjd�s-|dk	rB|jjrBt|_||_n
|j	|�dS(Nsflask._preserve_context(
RBRJR
RRtpreserve_context_on_exceptionRPRHRIR(RR9((s*/tmp/pip-install-sTXtzD/flask/flask/ctx.pytauto_pop�s
	cCs|j�|S(N(R4(R((s*/tmp/pip-install-sTXtzD/flask/flask/ctx.pyR;�s
cCs6|j|�tr2|dk	r2t|||�ndS(N(R`RRR(RR<R=R>((s*/tmp/pip-install-sTXtzD/flask/flask/ctx.pyR?�s
cCs,d|jj|jj|jj|jjfS(Ns<%s '%s' [%s] of %s>(RMRRBturltmethodRR(R((s*/tmp/pip-install-sTXtzD/flask/flask/ctx.pyR�s
			N(RRRRR0tpropertyR.tsetterR&RTR4RRR`R;R?R(((s*/tmp/pip-install-sTXtzD/flask/flask/ctx.pyR@�s 		
	+/				(RR3t	functoolsRtwerkzeug.exceptionsRt_compatRRtglobalsRRtsignalsRRRRRR R'R(R)R*R@(((s*/tmp/pip-install-sTXtzD/flask/flask/ctx.pyt<module>
s"	F		(	 	
2

https://t.me/AnonymousX5 - 2025