Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
ctx.cpython-313.pyc218 linesDownload Raw Back to __pycache__
1�

2��j�<���SSKJr SSKrSSKrSSKrSSKJr SSKJ	r	 SSK3Jr SSKJr
 SSKJr SS	KJr SS4KJr SSKJr \R((aSSKJr SS
KJr SSKJr SSKJr \"5r"SS5rSSjr \RB"S\RDS\RF4S9r$SSjr%SSjr&SSjr'"SS5r("SS5r)g) �)�annotationsN)�update_wrapper)�
TracebackType)�
HTTPException�)�typing)�_cv_app)�_cv_request)�appcontext_popped)�appcontext_pushed)�WSGIEnvironment)�Flask)�SessionMixin)�Requestc��\rSrSrSrSSjrSSjrSSjrSSSjjr\	4SSjjr5SSS	jjrSS6jrSSjr
SSjrS
rg)�_AppCtxGlobals�a�A plain object. Used as a namespace for storing data during an7application context.8 9Creating an app context automatically creates this object, which is10made available as the :data:`g` proxy.11 12.. describe:: 'key' in g13 14    Check whether an attribute is present.15 16    .. versionadded:: 0.1017 18.. describe:: iter(g)19 20    Return an iterator over the attribute names.21 22    .. versionadded:: 0.1023c�V�URU$![a
 [U5Sef=f�N��__dict__�KeyError�AttributeError��self�names  �OD:\code\apps\devtools\python\user_packages\Python313\site-packages\flask/ctx.py�__getattr__�_AppCtxGlobals.__getattr__4s2��	1��=�=��&�&���	1� ��&�D�0�	1�s��(c� �X RU'gr�r)rr�values   r�__setattr__�_AppCtxGlobals.__setattr__:s��#�
�
�d��c�T�URU	g![a
 [U5Sef=frrrs  r�__delattr__�_AppCtxGlobals.__delattr__=s/��	1��
�
�d�#���	1� ��&�D�0�	1�s�
�'Nc�8�URRX5$)z�Get an attribute by name, or a default value. Like24:meth:`dict.get`.25 26:param name: Name of attribute to get.27:param default: Value to return if the attribute is not present.28 29.. versionadded:: 0.1030)r�get�rr�defaults   rr*�_AppCtxGlobals.getCs���}�}� � ��/�/r%c��U[LaURRU5$URRX5$)z�Get and remove an attribute by name. Like :meth:`dict.pop`.31 32:param name: Name of attribute to pop.33:param default: Value to return if the attribute is not present,34    instead of raising a ``KeyError``.35 36.. versionadded:: 0.1137)�	_sentinelr�popr+s   rr0�_AppCtxGlobals.popNs6���i���=�=�$�$�T�*�*��=�=�$�$�T�3�3r%c�8�URRX5$)aGet the value of an attribute if it is present, otherwise38set and return a default value. Like :meth:`dict.setdefault`.39 40:param name: Name of attribute to get.41:param default: Value to set and return if the attribute is not42    present.43 44.. versionadded:: 0.1145)r�46setdefaultr+s   rr3�_AppCtxGlobals.setdefault\s���}�}�'�'��6�6r%c��XR;$rr!)r�items  r�__contains__�_AppCtxGlobals.__contains__hs���}�}�$�$r%c�,�[UR5$r)�iterr�rs r�__iter__�_AppCtxGlobals.__iter__ks���D�M�M�"�"r%c��[R"S5nUbSURRS3$[RU5$)Nz
<flask.g of 'z'>)r	r*�appr�object�__repr__)r�ctxs  rrA�_AppCtxGlobals.__repr__ns;���k�k�$����?�"�3�7�7�<�<�.��3�3����t�$�$r%�)r�str�return�t.Any)rrEr"rGrF�None)rrErFrHr)rrEr,zt.Any | NonerFrG)rrEr,rGrFrG)r6rErF�bool)rFzt.Iterator[str]�rFrE)�__name__�47__module__�__qualname__�__firstlineno__�__doc__rr#r'r*r/r0r3r7r<rA�__static_attributes__rDr%rrrs9���,1�$�1�	0�/8�4�487�%�#�%r%rc��[R"S5nUc[S5eURR	U5 U$)awExecutes a function after this request.  This is useful to modify49response objects.  The function is passed the response object and has50to return the same or a new one.51 52Example::53 54    @app.route('/')55    def index():56        @after_this_request57        def add_header(response):58            response.headers['X-Foo'] = 'Parachute'59            return response60        return 'Hello World!'61 62This is more useful if a function other than the view function wants to63modify a response.  For instance think of a decorator that wants to add64some headers without converting the return value into a response object.65 66.. versionadded:: 0.967Nzc'after_this_request' can only be used when a request context is active, such as in a view function.)r68r*�RuntimeError�_after_request_functions�append)�frBs  r�after_this_requestrVusD��.�/�/�$�69�C�70�{��
>�71�	72�73� � �'�'��*��Hr%�F.)�boundc�^^�[R"S5mTc[S5eTR5mSUU4Sjjn[	UT5$)a�A helper function that decorates a function to retain the current74request context.  This is useful when working with greenlets.  The moment75the function is decorated a copy of the request context is created and76then pushed when the function is called.  The current session is also77included in the copied request context.78 79Example::80 81    import gevent82    from flask import copy_current_request_context83 84    @app.route('/')85    def index():86        @copy_current_request_context87        def do_some_work():88            # do some work here, it can access flask.request or89            # flask.session like you would otherwise in the view function.90            ...91        gevent.spawn(do_some_work)92        return 'Regular response'93 94.. versionadded:: 0.1095Nzm'copy_current_request_context' can only be used when a request context is active, such as in a view function.c�>�T TRRT5"U0UD6sSSS5 $!,(df   g=fr)r?�ensure_sync)�args�kwargsrBrUs  ��r�wrapper�-copy_current_request_context.<locals>.wrapper�s,���
��7�7�&�&�q�)�4�:�6�:��S�S�s�!/�96=)r\rGr]rGrFrG)r97r*rR�copyr)rUr^rBs` @r�copy_current_request_contextra�sQ���0�/�/�$�98�C�99�{��
F�100�	101�102�(�(�*�C�;�;��'�1�%�%r%c�2�[R"S5SL$)a�If you have code that wants to test if a request context is there or103not this function can be used.  For instance, you may want to take advantage104of request information if the request object is available, but fail105silently if it is unavailable.106 107::108 109    class User(db.Model):110 111        def __init__(self, username, remote_addr=None):112            self.username = username113            if remote_addr is None and has_request_context():114                remote_addr = request.remote_addr115            self.remote_addr = remote_addr116 117Alternatively you can also just test any of the context bound objects118(such as :class:`request` or :class:`g`) for truthness::119 120    class User(db.Model):121 122        def __init__(self, username, remote_addr=None):123            self.username = username124            if remote_addr is None and request:125                remote_addr = request.remote_addr126            self.remote_addr = remote_addr127 128.. versionadded:: 0.7129N)r130r*rDr%r�has_request_contextrc�s��:�?�?�4� ��,�,r%c�2�[R"S5SL$)z�Works like :func:`has_request_context` but for the application131context.  You can also just do a boolean check on the132:data:`current_app` object instead.133 134.. versionadded:: 0.9135N)r	r*rDr%r�has_app_contextre�s���;�;�t��D�(�(r%c�`�\rSrSrSrS136SjrSSjr\4SSjjrS
Sjr	SSjr137Srg	)�138AppContext��z�The app context contains application-specific information. An app139context is created and pushed at the beginning of each request if140one is not already active. An app context is also pushed when141running CLI commands.142c�t�XlURS5UlUR5Ul/Ulgr)r?�create_url_adapter�url_adapter�app_ctx_globals_class�g�143_cv_tokens)rr?s  r�__init__�AppContext.__init__�s1�����1�1�$�7���!$�!:�!:�!<���?A��r%c���URR[R"U55 [R144"URURRS9 g)z-Binds the app context to the current context.��_async_wrapperN)rnrTr	�setr�sendr?r[r;s r�push�AppContext.push�s;�������w�{�{�4�0�1����t�x�x����8L�8L�Mr%c�\�[UR5S:Xa<U[La[R"5SnUR145R
U5 [R"5n[R"URR55 X La[SU<SU<S35e[R"UR146UR147RS9 g![R"5n[R"URR55 f=f)zPops the app context.rzPopped wrong app context. (� instead of �)rrN)�lenrnr/�sys�exc_infor?�do_teardown_appcontextr	r*�resetr0�AssertionErrorrrur[)r�excrBs   rr0�AppContext.pops���	1��4�?�?�#�q�(��)�#��,�,�.��+�C����/�/��4��+�+�-�C��M�M�$�/�/�-�-�/�0��?� �-�c�W�L����J��
�	���t�x�x����8L�8L�M���+�+�-�C��M�M�$�/�/�-�-�/�0�s
�AC&�&AD+c�&�UR5 U$r�rvr;s r�	__enter__�AppContext.__enter__����	�	���r%c�&�URU5 gr�r0�r�exc_type�	exc_value�tbs    r�__exit__�AppContext.__exit__���	
����r%)rnr?rmrkN)r?rrFrH�rFrH�r��BaseException | NonerFrH)rFrg�r�ztype | Noner�r�r�zTracebackType | NonerFrH)rKrLrMrNrOrorvr/r0r�r�rPrDr%rrgrg�sN���B�N�148/8�N�$����(��
!�	�149150�r%rgc��\rSrSrSrSSSjjrSSjrSSjr\SSj5r	SSjr151\4SS	jjrSS152jr
SSjrSSjrS
rg)�RequestContextia�The request context contains per-request information. The Flask153app creates and pushes it at the beginning of the request, then pops154it at the end of the request. It will create the URL adapter and155request object for the WSGI environment provided.156 157Do not attempt to use this class directly, instead use158:meth:`~flask.Flask.test_request_context` and159:meth:`~flask.Flask.request_context` to create this object.160 161When the request context is popped, it will evaluate all the162functions registered on the application for teardown execution163(:meth:`~flask.Flask.teardown_request`).164 165The request context is automatically popped at the end of the166request. When using the interactive debugger, the context will be167restored so ``request`` is still accessible. Similarly, the test168client can preserve the context after the request ends. However,169teardown functions may already have closed some resources such as170database connections.171Nc�:�XlUc"URU5nURUlX0lSUlUR
UR5UlSUl	X@l172/Ul/Ulg![anXPRlSnAN;SnAff=fr)
r?�
request_class�json�json_module�requestrkrjr�routing_exception�flashes�_sessionrSrn)rr?�environr��session�es      rro�RequestContext.__init__5s������?��'�'��0�G�"%�(�(�G�� '�����	/�"�5�5�d�l�l�C�D��6:���-4�
�OQ��%�
�	
����	/�-.�L�L�*�*��	/�s� A6�6173B�B�Bc��URURURRURURS9$)a�Creates a copy of this request context with the same request object.174This can be used to move a request context to a different greenlet.175Because the actual request object is the same this cannot be used to176move a request context to a different thread unless access to the177request object is locked.178 179.. versionadded:: 0.10180 181.. versionchanged:: 1.1182   The current session object is used instead of reloading the original183   data. This prevents `flask.session` pointing to an out-of-date object.184)r�r�r�)�	__class__r?r�r�r�r;s rr`�RequestContext.copyQs<���~�~��H�H��L�L�(�(��L�L��M�M�	�185�	186r%c���URRSS9nUuURlURlg![187anX RlSnAgSnAff=f)zJCan be overridden by a subclass to hook into the matching188of the request.189T)�return_ruleN)rk�matchr��url_rule�	view_argsrr�)r�resultr�s   r�
match_request�RequestContext.match_requestesU��	/��%�%�+�+��+�=�F�<B�9�D�L�L�!�4�<�<�#9���	/�-.�L�L�*�*��	/�s�<?�190A#�	A�A#c�d�URcS5eSURlUR$)z�The session data associated with this request. Not available until191this context has been pushed. Accessing this property, also accessed by192the :data:`~flask.session` proxy, sets :attr:`.SessionMixin.accessed`.193z$The session has not yet been opened.T)r��accessedr;s rr��RequestContext.sessionos0���}�}�(�P�*P�P�(�!%��
�
���}�}�r%c�V�[R"S5nUbURURLa+URR5nUR	5 OSnUR194R
[R"U5U45 URcnURRnURURUR5Ul	URc URUR5Ul	URbUR5 ggr)r	r*r?�app_contextrvrnrTr195rtr��session_interface�open_sessionr��make_null_sessionrkr�)r�app_ctxr�s   rrv�RequestContext.pushys����+�+�d�#���?�g�k�k����9��h�h�*�*�,�G��L�L�N��G���������� 5�w�?�@��=�=� � $��� :� :��-�:�:�4�8�8�T�\�\�R�D�M��}�}�$� 1� C� C�D�H�H� M��
����'���� �(r%c	�T�[UR5S:HnU(a]U[La[R"5SnUR196R
U5 [URSS5nUbU"5 [R"5nURR5upV[R"U5 U(aSURRS'UbURU5 X@La[SU<SU<S35eg![R"5nURR5upV[R"U5 U(aSURRS'UbURU5 X@La[SU<SU<S35ef=f)z�Pops the request context and unbinds it by doing that.  This will197also trigger the execution of functions registered by the198:meth:`~flask.Flask.teardown_request` decorator.199 200.. versionchanged:: 0.9201   Added the `exc` argument.202r�closeNzwerkzeug.requestzPopped wrong request context. (ryrz)r{rnr/r|r}r?�do_teardown_request�getattrr�r203r*r0rr�r�)rr��
clear_request�
request_closerB�tokenr�s       rr0�RequestContext.pop�sr���D�O�O�,��1�
�	���)�#��,�,�.��+�C����,�,�S�1� '����g�t� D�
� �,�!�O��/�/�#�C�!�_�_�0�0�2�N�E����e�$��:>����#�#�$6�7��"����C� ���$�5�c�W�L���PQ�R������/�/�#�C�!�_�_�0�0�2�N�E����e�$��:>����#�#�$6�7��"����C� ���$�5�c�W�L���PQ�R����s
�A$D�BF'c�&�UR5 U$rr�r;s rr��RequestContext.__enter__�r�r%c�&�URU5 grr�r�s    rr��RequestContext.__exit__�r�r%c	���S[U5RSURR<SURRSUR204RS3	$)N�<� z [z] of �>)�typerKr��url�methodr?rr;s rrA�RequestContext.__repr__�sQ����T�205�#�#�$�A�d�l�l�&6�&6�%9�����$�$�%�U�4�8�8�=�=�/��
<�	206r%)rSrnr�r?r�r�rk)NN)207r?rr�r
r�zRequest | Noner�zSessionMixin | NonerFrH)rFr�r�)rFrr�r�rJ)rKrLrMrNrOror`r��propertyr�rvr/r0r�r�rArPrDr%rr�r�s����2#'�'+��
��!�� �	�208%��209�
�8210�(/�����!�:/8�#�J����(��
!�	�211212��213r%r�)rU�ft.AfterRequestCallable[t.Any]rFr�)rUrWrFrW)rFrI)*�214__future__r�contextvarsr|r�t�	functoolsr�typesr�werkzeug.exceptionsr��ft�globalsr	r215�signalsrr�
TYPE_CHECKING�_typeshed.wsgir
r?r�sessionsr�wrappersrr@r/rrV�TypeVar�Callable�AnyrWrarcrergr�rDr%r�<module>r�s���"��216��$��-��� �&�&��?�?�.��&�!�
�H�	�U%�U%�p 
�%� 
�#� 
�F�I�I�c����C����J�/�0��&&�R-�@)�.�.�bl217�l218r%
codekingpro/portable-devtools · Team Ai