Files
proxmox/venv/lib/python3.12/site-packages/flask/__pycache__/ctx.cpython-312.pyc

212 lines
19 KiB
Plaintext
Raw Normal View History

<EFBFBD>
<0E>Hi<48>:<00><01><><00>ddlmZddlZddlZddlZddlmZddlm Z ddl
m Z ddl mZ ddlmZdd lmZdd
lmZdd lmZej(rdd lmZdd lmZddlmZddlmZe<1D>ZGd<10>d<11>Z dd<12>Z ejBdejDdejFf<00><15>Z$dd<16>Z%dd<17>Z&dd<18>Z'Gd<19>d<1A>Z(Gd<1B>d<1C>Z)y) <20>)<01> annotationsN)<01>update_wrapper)<01> TracebackType)<01> HTTPException<6F>)<01>typing)<01>_cv_app)<01> _cv_request)<01>appcontext_popped)<01>appcontext_pushed)<01>WSGIEnvironment)<01>Flask)<01> SessionMixin)<01>Requestc<01>`<00>eZdZdZd d<02>Zd d<03>Zdd<04>Zddd<06>Zefdd<07>Z ddd<08>Z
dd <09>Z dd
<EFBFBD>Z dd <0B>Z y)<15>_AppCtxGlobalsa<73>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
c<01>T<00> |j|S#t$r t|<01>d<00>wxYw<01>N<><03>__dict__<5F>KeyError<6F>AttributeError<6F><02>self<6C>names <20>K/home/intlc/projects/proxmox/venv/lib/python3.12/site-packages/flask/ctx.py<70> __getattr__z_AppCtxGlobals.__getattr__4s2<00><00> 1<><17>=<3D>=<3D><14>&<26> &<26><><17> 1<> <20><14>&<26>D<EFBFBD> 0<> 1<>s<00><00>'c<01>"<00>||j|<yr<00>r)rr<00>values r<00> __setattr__z_AppCtxGlobals.__setattr__:s<00><00>#<23><04> <0A> <0A>d<EFBFBD><1B>c<01>R<00> |j|=y#t$r t|<01>d<00>wxYwrrrs r<00> __delattr__z_AppCtxGlobals.__delattr__=s/<00><00> 1<><14> <0A> <0A>d<EFBFBD>#<23><><17> 1<> <20><14>&<26>D<EFBFBD> 0<> 1<>s<00> <00>&Nc<01>:<00>|jj||<02>S)z<>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
)r<00>get<65>rr<00>defaults rr&z_AppCtxGlobals.getCs<00><00><14>}<7D>}<7D> <20> <20><14>w<EFBFBD>/<2F>/r"c<01><><00>|tur|jj|<01>S|jj||<02>S)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
)<03> _sentinelr<00>popr's rr+z_AppCtxGlobals.popNs8<00><00> <13>i<EFBFBD> <1F><17>=<3D>=<3D>$<24>$<24>T<EFBFBD>*<2A> *<2A><17>=<3D>=<3D>$<24>$<24>T<EFBFBD>7<EFBFBD>3<> 3r"c<01>:<00>|jj||<02>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<00>
setdefaultr's rr-z_AppCtxGlobals.setdefault\s<00><00><14>}<7D>}<7D>'<27>'<27><04>g<EFBFBD>6<>6r"c<01><00>||jvSrr)r<00>items r<00> __contains__z_AppCtxGlobals.__contains__hs<00><00><13>t<EFBFBD>}<7D>}<7D>$<24>$r"c<01>,<00>t|j<00>Sr)<02>iterr<00>rs r<00>__iter__z_AppCtxGlobals.__iter__ks<00><00><13>D<EFBFBD>M<EFBFBD>M<EFBFBD>"<22>"r"c<01><><00>tjd<00>}|<01>d|jj<00>d<02>Stj |<00>S)Nz <flask.g of 'z'>)r r&<00>appr<00>object<63>__repr__)r<00>ctxs rr8z_AppCtxGlobals.__repr__ns;<00><00><15>k<EFBFBD>k<EFBFBD>$<24><1F><03> <0E>?<3F>"<22>3<EFBFBD>7<EFBFBD>7<EFBFBD><<3C><<3C>.<2E><02>3<> 3<><15><EFBFBD><EFBFBD>t<EFBFBD>$<24>$r")r<00>str<74>return<72>t.Any)rr:r r<r;<00>None)rr:r;r=r)rr:r(z t.Any | Noner;r<)rr:r(r<r;r<)r/r:r;<00>bool)r;zt.Iterator[str]<5D>r;r:)<0E>__name__<5F>
__module__<EFBFBD> __qualname__<5F>__doc__rr!r$r&r*r+r-r0r4r8<00>r"rrrs9<00><00><08>,1<> $<24>1<> 0<>/8<> 4<>
7<>%<25>#<23>%r"rc<01><><00>tjd<01>}|<01> td<02><00>|jj |<00>|S)a<>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
Nzc'after_this_request' can only be used when a request context is active, such as in a view function.)r
r&<00> RuntimeError<6F>_after_request_functions<6E>append)<02>fr9s r<00>after_this_requestrJusD<00><00>. <16>/<2F>/<2F>$<24>
<1F>C<EFBFBD>
<EFBFBD>{<7B><1A> ><3E>
<EFBFBD>
<EFBFBD>
<08> <20> <20>'<27>'<27><01>*<2A> <0C>Hr"<00>F.)<01>boundc<01><><00><00><02>tjd<01><00><02><02> td<02><00><01>j<00><00>d<04><02>fd<03> }t |<01><00>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
Nzm'copy_current_request_context' can only be used when a request context is active, such as in a view function.c<01>v<00><02><00>5<00>jj<00><03>|i|<01><01>cddd<00>S#1swYyxYwr)r6<00> ensure_sync)<04>args<67>kwargsr9rIs <20><>r<00>wrapperz-copy_current_request_context.<locals>.wrapper<65>s9<00><><00> <10> ;<3B>)<29>3<EFBFBD>7<EFBFBD>7<EFBFBD>&<26>&<26>q<EFBFBD>)<29>4<EFBFBD>:<3A>6<EFBFBD>:<3A> ;<3B> ;<3B> ;<3B>s<00>!/<03>8)rPr<rQr<r;r<)r
r&rF<00>copyr)rIrRr9s` @r<00>copy_current_request_contextrT<00>sL<00><><00>0 <16>/<2F>/<2F>$<24>
<1F>C<EFBFBD>
<EFBFBD>{<7B><1A> F<01>
<EFBFBD>
<EFBFBD>
<0E>(<28>(<28>*<2A>C<EFBFBD>;<3B> <1A>'<27>1<EFBFBD> %<25>%r"c<01>0<00>tjd<01>duS)a<>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)r
r&rDr"r<00>has_request_contextrV<00>s<00><00>: <17>?<3F>?<3F>4<EFBFBD> <20><04> ,<2C>,r"c<01>0<00>tjd<01>duS)z<>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)r r&rDr"r<00>has_app_contextrX<00>s<00><00> <13>;<3B>;<3B>t<EFBFBD> <1C>D<EFBFBD> (<28>(r"c<01>L<00>eZdZdZdd<02>Zd d<03>Zefd
d<04>Zd d<05>Z d d<06>Z y) <0A>
AppContextz<EFBFBD>The app context contains application-specific information. An app
context is created and pushed at the beginning of each request if
one is not already active. An app context is also pushed when
running CLI commands.
c<01>v<00>||_|jd<00>|_|j<00>|_g|_yr)r6<00>create_url_adapter<65> url_adapter<65>app_ctx_globals_class<73>g<>
_cv_tokens)rr6s r<00>__init__zAppContext.__init__<5F>s3<00><00><16><04><08><1E>1<>1<>$<24>7<><04><18>!$<24>!:<3A>!:<3A>!<<3C><04><06>?A<><04>r"c<01><><00>|jjtj|<00><00>t j
|j |j j<00><01>y)z-Binds the app context to the current context.<2E><01>_async_wrapperN)r`rHr <00>setr <00>sendr6rOr3s r<00>pushzAppContext.push<73>s;<00><00> <0C><0F><0F><1E><1E>w<EFBFBD>{<7B>{<7B>4<EFBFBD>0<>1<><19><1E><1E>t<EFBFBD>x<EFBFBD>x<EFBFBD><04><08><08>8L<38>8L<38>Mr"c<01>N<00> t|j<00>dk(r:|turtj<00>d}|j
j |<01>tj<00>}tj|jj<00><00>||urtd|<02>d|<00>d<04><05><00>tj|j
|j
j<00><05>y#tj<00>}tj|jj<00><00>wxYw)zPops the app context.rzPopped wrong app context. (<28> instead of <20>)rcN)<0F>lenr`r*<00>sys<79>exc_infor6<00>do_teardown_appcontextr r&<00>resetr+<00>AssertionErrorr rfrO)r<00>excr9s rr+zAppContext.pops<><00><00> 1<><12>4<EFBFBD>?<3F>?<3F>#<23>q<EFBFBD>(<28><16>)<29>#<23><1D>,<2C>,<2C>.<2E><11>+<2B>C<EFBFBD><14><08><08>/<2F>/<2F><03>4<><19>+<2B>+<2B>-<2D>C<EFBFBD> <13>M<EFBFBD>M<EFBFBD>$<24>/<2F>/<2F>-<2D>-<2D>/<2F> 0<> <0E>d<EFBFBD>?<3F> <20>-<2D>c<EFBFBD>W<EFBFBD>L<EFBFBD><14><08><01>J<><0E> <0E> <1A><1E><1E>t<EFBFBD>x<EFBFBD>x<EFBFBD><04><08><08>8L<38>8L<38>M<><4D><1A>+<2B>+<2B>-<2D>C<EFBFBD> <13>M<EFBFBD>M<EFBFBD>$<24>/<2F>/<2F>-<2D>-<2D>/<2F> 0<>s <00>AC!<00>!AD$c<01>&<00>|j<00>|Sr<00>rgr3s r<00> __enter__zAppContext.__enter__<00><00><00> <0C> <09> <09> <0B><13> r"c<01>&<00>|j|<02>yr<00>r+<00>r<00>exc_type<70> exc_value<75>tbs r<00>__exit__zAppContext.__exit__<00><00><00> <0A><08><08><19>r"N)r6rr;r=<00>r;r=<00>rq<00>BaseException | Noner;r=)r;rZ<00>ryz type | Nonerzr<>r{zTracebackType | Noner;r=)
r@rArBrCrargr*r+rtr|rDr"rrZrZ<00>sN<00><00><08> B<01> N<01>
/8<>N<01>$<14><1C><1D><1C>(<28><1C> !<21> <1C>
<0E> r"rZc<01>|<00>eZdZdZ d d d<03>Zd d<04>Zdd<05>Zdd<06>Zefdd<07>Z d d<08>Z
dd <09>Z dd
<EFBFBD>Z y)<12>RequestContexta<74>The request context contains per-request information. The Flask
app creates and pushes it at the beginning of the request, then pops
it at the end of the request. 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. When using the interactive debugger, the context will be
restored so ``request`` is still accessible. Similarly, the test
client can preserve the context after the request ends. However,
teardown functions may already have closed some resources such as
database connections.
Nc<01>><00>||_|<03>"|j|<02>}|j|_||_d|_ |j |j<00>|_d|_ ||_
g|_ g|_ y#t$r}||j_Yd}~<05><d}~wwxYwr) r6<00> request_class<73>json<6F> json_module<6C>requestr]r\r<00>routing_exception<6F>flashes<65>sessionrGr`)rr6<00>environr<6E>r<><00>es rrazRequestContext.__init__5s<><00><00><17><04><08> <12>?<3F><19>'<27>'<27><07>0<>G<EFBFBD>"%<25>(<28>(<28>G<EFBFBD> <1F> '<27><04> <0C><1F><04><18> /<2F>"<22>5<>5<>d<EFBFBD>l<EFBFBD>l<EFBFBD>C<>D<EFBFBD> <1C>6:<3A><04> <0C>,3<><04> <0C>OQ<01><04>%<25> <0F> <0A><0F><><1D> /<2F>-.<2E>D<EFBFBD>L<EFBFBD>L<EFBFBD> *<2A> *<2A><> /<2F>s<00> A8<00>8 B<03>B<03>Bc<01><><00>|j|j|jj|j|j<00><01>S)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.
)r<>r<>r<>)<05> __class__r6r<>r<>r<>r3s rrSzRequestContext.copyQs<<00><00><14>~<7E>~<7E> <10>H<EFBFBD>H<EFBFBD><18>L<EFBFBD>L<EFBFBD>(<28>(<28><18>L<EFBFBD>L<EFBFBD><18>L<EFBFBD>L<EFBFBD> <1E>
<EFBFBD>
r"c<01><><00> |jjd<01><02>}|\|j_|j_y#t
$r}||j_Yd}~yd}~wwxYw)zZCan be overridden by a subclass to hook into the matching
of the request.
T)<01> return_ruleN)r]<00>matchr<68><00>url_rule<6C> view_argsrr<>)r<00>resultr<74>s r<00> match_requestzRequestContext.match_requestesW<00><00> /<2F><19>%<25>%<25>+<2B>+<2B><04>+<2B>=<3D>F<EFBFBD><B<> 9<>D<EFBFBD>L<EFBFBD>L<EFBFBD> !<21>4<EFBFBD><<3C><<3C>#9<><39><1C> /<2F>-.<2E>D<EFBFBD>L<EFBFBD>L<EFBFBD> *<2A> *<2A><> /<2F>s<00>?A<00> A&<03> A!<03>!A&c<01>H<00>tjd<00>}|<01>|j|jur+|jj<00>}|j <00>nd}|j
j tj|<00>|f<02>|j<00>m|jj}|j|j|j<00>|_ |j<00> |j|j<00>|_ |j<00>|j<00>yyr)r r&r6<00> app_contextrgr`rHr
rer<><00>session_interface<63> open_sessionr<6E><00>make_null_sessionr]r<>)r<00>app_ctxr<78>s rrgzRequestContext.pushos<><00><00><1A>+<2B>+<2B>d<EFBFBD>#<23><07> <12>?<3F>g<EFBFBD>k<EFBFBD>k<EFBFBD><14><18><18>9<><1A>h<EFBFBD>h<EFBFBD>*<2A>*<2A>,<2C>G<EFBFBD> <13>L<EFBFBD>L<EFBFBD>N<EFBFBD><1A>G<EFBFBD> <0C><0F><0F><1E><1E> <0B><0F><0F><04> 5<>w<EFBFBD>?<3F>@<40> <10><<3C><<3C> <1F> $<24><08><08> :<3A> :<3A> <1D>,<2C>9<>9<>$<24>(<28>(<28>D<EFBFBD>L<EFBFBD>L<EFBFBD>Q<>D<EFBFBD>L<EFBFBD><13>|<7C>|<7C>#<23>0<>B<>B<>4<EFBFBD>8<EFBFBD>8<EFBFBD>L<><04> <0C> <10> <1B> <1B> '<27> <10> <1E> <1E> <20> (r"c <01> <00>t|j<00>dk(} |rZ|turtj<00>d}|j
j |<01>t|jdd<03>}|<03>|<03>tj<00>}|jj<00>\}}tj|<05>|rd|jjd<|<06>|j|<01>||urtd|<04>d|<00>d<07><05><00>y#tj<00>}|jj<00>\}}tj|<05>|rd|jjd<|<06>|j|<01>||urtd|<04>d|<00>d<07><05><00>wxYw)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.
r<00>closeNzwerkzeug.requestzPopped wrong request context. (rirj)rkr`r*rlrmr6<00>do_teardown_request<73>getattrr<72>r
r&r+ror<>rp)rrq<00> clear_request<73> request_closer9<00>tokenr<6E>s rr+zRequestContext.pop<6F>sz<00><00><1C>D<EFBFBD>O<EFBFBD>O<EFBFBD>,<2C><01>1<> <0A> <12><1C><16>)<29>#<23><1D>,<2C>,<2C>.<2E><11>+<2B>C<EFBFBD><14><08><08>,<2C>,<2C>S<EFBFBD>1<> '<27><04> <0C> <0C>g<EFBFBD>t<EFBFBD> D<> <0A> <20>,<2C>!<21>O<EFBFBD><1D>/<2F>/<2F>#<23>C<EFBFBD>!<21>_<EFBFBD>_<EFBFBD>0<>0<>2<>N<EFBFBD>E<EFBFBD>7<EFBFBD> <17> <1D> <1D>e<EFBFBD> $<24><1D>:><3E><03> <0B> <0B>#<23>#<23>$6<>7<><16>"<22><17> <0B> <0B>C<EFBFBD> <20><12>$<24><EFBFBD>$<24>5<>c<EFBFBD>W<EFBFBD>L<EFBFBD><14><08>PQ<50>R<><12><12><1F><><1E>/<2F>/<2F>#<23>C<EFBFBD>!<21>_<EFBFBD>_<EFBFBD>0<>0<>2<>N<EFBFBD>E<EFBFBD>7<EFBFBD> <17> <1D> <1D>e<EFBFBD> $<24><1D>:><3E><03> <0B> <0B>#<23>#<23>$6<>7<><16>"<22><17> <0B> <0B>C<EFBFBD> <20><12>$<24><EFBFBD>$<24>5<>c<EFBFBD>W<EFBFBD>L<EFBFBD><14><08>PQ<50>R<><12><12><1F>s <00>AD<00>B F c<01>&<00>|j<00>|Srrsr3s rrtzRequestContext.__enter__<5F>rur"c<01>&<00>|j|<02>yrrwrxs rr|zRequestContext.__exit__<5F>r}r"c <01><><00>dt|<00>j<00>d|jj<00>d|jj<00>d|j
j <00>d<05> S)N<><<3C> z [z] of <20>>)<07>typer@r<><00>url<72>methodr6rr3s rr8zRequestContext.__repr__<5F>sQ<00><00><0F><04>T<EFBFBD>
<EFBFBD>#<23>#<23>$<24>A<EFBFBD>d<EFBFBD>l<EFBFBD>l<EFBFBD>&6<>&6<>%9<><10><14><1C><1C>$<24>$<24>%<25>U<EFBFBD>4<EFBFBD>8<EFBFBD>8<EFBFBD>=<3D>=<3D>/<2F><11> <<3C>
r")NN)
r6rr<>r r<>zRequest | Noner<65>zSessionMixin | Noner;r=)r;r<>r~rr<>r?) r@rArBrCrarSr<>rgr*r+rtr|r8rDr"rr<>r<>s<><00><00><08>2#'<27>'+<2B> <0F> <12><0F>!<21><0F> <20> <0F>
%<25> <0F>
<0E> <0F>8
<EFBFBD>(/<2F>!<21>:/8<>#<12>J<14><1C><1D><1C>(<28><1C> !<21> <1C>
<0E> <1C>
r"r<>)rI<00>ft.AfterRequestCallable[t.Any]r;r<>)rIrKr;rK)r;r>)*<2A>
__future__r<00> contextvarsrlr<00>t<> functoolsr<00>typesr<00>werkzeug.exceptionsr<00><00>ft<66>globalsr r
<00>signalsr r <00> TYPE_CHECKING<4E>_typeshed.wsgir r6r<00>sessionsr<00>wrappersrr7r*rrJ<00>TypeVar<61>Callable<6C>AnyrKrTrVrXrZr<>rDr"r<00><module>r<>s<><00><01>"<22><12>
<EFBFBD><12>$<24><1F>-<2D><1A><1C> <20>&<26>&<26><04>?<3F>?<3F>.<2E><1A>&<26>!<21> <13>H<EFBFBD> <09>U%<25>U%<25>p  <0A>%<25>  <0A>#<23>  <0A>F<0E>A<EFBFBD>I<EFBFBD>I<EFBFBD>c<EFBFBD><11><1A><1A>C<EFBFBD><11><15><15>J<EFBFBD>/<2F>0<><01>&&<26>R-<2D>@)<29>.<1C>.<1C>bb
<EFBFBD>b
r"