Files
old-parkingkoncept/parkingkonceptvenv/lib/python3.7/site-packages/werkzeug/__pycache__/local.cpython-37.pyc

189 lines
18 KiB
Plaintext
Raw Normal View History

2019-11-17 12:44:16 +01:00
B
<00>/<2F>]x8<00> @s<>dZddlZddlmZddlmZddlmZddlmZyddl m
Z WnFe k
r<EFBFBD>ydd l m Z Wn e k
r<EFBFBD>dd lm Z YnXYnXd
d <0B>ZGd d <0A>d e<10>ZGdd<0F>de<10>ZGdd<11>de<10>ZeGdd<13>de<10><03>ZdS)z<>
werkzeug.local
~~~~~~~~~~~~~~
This module implements context-local objects.
:copyright: 2007 Pallets
:license: BSD-3-Clause
<EFBFBD>N)<01>update_wrapper<65>)<01>implements_bool)<01>PY2)<01>ClosingIterator)<01>
getcurrent)<01> get_identcCs |<00><00>dS)aMReleases the contents of the local for the current context.
This makes it possible to use locals without a manager.
Example::
>>> loc = Local()
>>> loc.foo = 42
>>> release_local(loc)
>>> hasattr(loc, 'foo')
False
With this function one can release :class:`Local` objects as well
as :class:`LocalStack` objects. However it is not possible to
release data held by proxies that way, one always has to retain
a reference to the underlying local object in order to be able
to release it.
.. versionadded:: 0.6.1
N)<01>__release_local__)<01>local<61>r <00>4/tmp/pip-install-c3kgu56x/Werkzeug/werkzeug/local.py<70> release_localsr c@sHeZdZdZdd<03>Zdd<05>Zdd<07>Zdd <09>Zd
d <0B>Zd d <0A>Z dd<0F>Z
dS)<11>Local)<02> __storage__<5F>__ident_func__cCs t<00>|di<00>t<00>|dt<02>dS)Nrr)<03>object<63> __setattr__r)<01>selfr r r <00>__init__8szLocal.__init__cCst|j<01><02><00>S)N)<03>iterr<00>items)rr r r <00>__iter__<szLocal.__iter__cCs
t||<01>S)zCreate a proxy for a name.)<01>
LocalProxy)r<00>proxyr r r <00>__call__?szLocal.__call__cCs|j<00>|<00><02>d<00>dS)N)r<00>popr)rr r r r CszLocal.__release_local__cCs4y|j|<00><01>|Stk
r.t|<01><01>YnXdS)N)rr<00>KeyError<6F>AttributeError)r<00>namer r r <00> __getattr__FszLocal.__getattr__cCsD|<00><00>}|j}y||||<Wn tk
r>||i||<YnXdS)N)rrr)rr<00>value<75>identZstorager r r rLs zLocal.__setattr__cCs6y|j|<00><01>|=Wntk
r0t|<01><01>YnXdS)N)rrrr)rrr r r <00> __delattr__TszLocal.__delattr__N) <0B>__name__<5F>
__module__<EFBFBD> __qualname__<5F> __slots__rrrr rrr"r r r r r5src@sbeZdZdZdd<03>Zdd<05>Zdd<07>Zdd <09>Zeee<07>Z [[d
d <0B>Z
d d <0A>Z dd<0F>Z edd<11><00>Z dS)<13>
LocalStacka<EFBFBD>This class works similar to a :class:`Local` but keeps a stack
of objects instead. This is best explained with an example::
>>> ls = LocalStack()
>>> ls.push(42)
>>> ls.top
42
>>> ls.push(23)
>>> ls.top
23
>>> ls.pop()
23
>>> ls.top
42
They can be force released by using a :class:`LocalManager` or with
the :func:`release_local` function but the correct way is to pop the
item from the stack after using. When the stack is empty it will
no longer be bound to the current context (and as such released).
By calling the stack without arguments it returns a proxy that resolves to
the topmost item on the stack.
.. versionadded:: 0.6.1
cCs t<00>|_dS)N)r<00>_local)rr r r rvszLocalStack.__init__cCs|j<00><01>dS)N)r(r )rr r r r yszLocalStack.__release_local__cCs|jjS)N)r(r)rr r r <00>_get__ident_func__|szLocalStack._get__ident_func__cCst<00>|jd|<01>dS)Nr)rrr()rr r r r <00>_set__ident_func__szLocalStack._set__ident_func__cs<00>fdd<02>}t|<01>S)Ncs<00>j}|dkrtd<01><01>|S)Nzobject unbound)<02>top<6F> RuntimeError)<01>rv)rr r <00>_lookup<75>sz$LocalStack.__call__.<locals>._lookup)r)rr.r )rr r<00>s zLocalStack.__call__cCs0t|jdd<02>}|dkr"g|j_}|<02>|<01>|S)zPushes a new item to the stack<63>stackN)<04>getattrr(r/<00>append)r<00>objr-r r r <00>push<73>s
 
zLocalStack.pushcCsDt|jdd<02>}|dkrdSt|<01>dkr8t|j<01>|dS|<01><04>SdS)z}Removes the topmost item from the stack, will return the
old value or `None` if the stack was already empty.
r/Nr<00><><EFBFBD><EFBFBD><EFBFBD>)r0r(<00>lenr r)rr/r r r r<00>s 
zLocalStack.popc Cs*y |jjdSttfk
r$dSXdS)z[The topmost item on the stack. If the stack is empty,
`None` is returned.
r4N)r(r/r<00>
IndexError)rr r r r+<00>s zLocalStack.topN)r#r$r%<00>__doc__rr r)r*<00>propertyrrr3rr+r r r r r'[s
  r'c@sBeZdZdZddd<04>Zdd<06>Zdd<08>Zd d
<EFBFBD>Zd d <0C>Zd d<0E>Z dS)<10> LocalManageraNLocal objects cannot manage themselves. For that you need a local
manager. You can pass a local manager multiple locals or add them later
by appending them to `manager.locals`. Every time the manager cleans up,
it will clean up all the data left in the locals for this context.
The `ident_func` parameter can be added to override the default ident
function for the wrapped locals.
.. versionchanged:: 0.6.1
Instead of a manager the :func:`release_local` function can be used
as well.
.. versionchanged:: 0.7
`ident_func` was added.
NcCsf|dkrg|_nt|t<02>r$|g|_n
t|<01>|_|dk r\||_x$|jD]}t<05>|d|<02>qDWnt|_dS)Nr)<08>locals<6C>
isinstancer<00>list<73>
ident_funcrrr)rr:r=r
r r r r<00>s


 zLocalManager.__init__cCs|<00><00>S)a<>Return the context identifier the local objects use internally for
this context. You cannot override this method to change the behavior
but use it to link other context local objects (such as SQLAlchemy's
scoped sessions) to the Werkzeug locals.
.. versionchanged:: 0.7
You can pass a different ident function to the local manager that
will then be propagated to all the locals passed to the
constructor.
)r=)rr r r r<00>s zLocalManager.get_identcCsx|jD] }t|<01>qWdS)z<>Manually clean up the data in the locals for this context. Call
this at the end of the request or use `make_middleware()`.
N)r:r )rr
r r r <00>cleanup<75>s zLocalManager.cleanupcs<00><00>fdd<02>}|S)zWWrap a WSGI application so that cleaning up happens after
request end.
cst<00>||<01><02>j<01>S)N)rr>)<02>environZstart_response)<02>apprr r <00> application<6F>sz1LocalManager.make_middleware.<locals>.applicationr )rr@rAr )r@rr <00>make_middleware<72>szLocalManager.make_middlewarecCst|<00>|<01>|<01>S)asLike `make_middleware` but for decorating functions.
Example usage::
@manager.middleware
def application(environ, start_response):
...
The difference to `make_middleware` is that the function passed
will have all the arguments copied from the inner application
(name, docstring, module).
)rrB)r<00>funcr r r <00>
middleware<EFBFBD>s zLocalManager.middlewarecCsd|jjt|j<03>fS)Nz<%s storages: %d>)<04> __class__r#r5r:)rr r r <00>__repr__<5F>szLocalManager.__repr__)NN)
r#r$r%r7rrr>rBrDrFr r r r r9<00>s
 
r9c@sBeZdZdZdZdTdd<05>Zdd<07>Zedd <09><00>Zd
d <0B>Z d d <0A>Z
dd<0F>Z dd<11>Z dd<13>Z dd<15>Zdd<17>Zer<>dd<19>Zdd<1B>Zdd<1D>Zdd<19>Zdd<19>Zd d<19>Zd!d<19>Zd"d<19>Zd#d<19>Zd$d<19>Zd%d<19>Zd&d<19>Zd'd<19>Zd(d<19>Zd)d<19>Zd*d<19>Z d+d<19>Z!d,d<19>Z"d-d<19>Z#d.d<19>Z$d/d<19>Z%d0d<19>Z&d1d<19>Z'd2d<19>Z(d3d<19>Z)d4d<19>Z*d5d<19>Z+d6d<19>Z,d7d<19>Z-d8d<19>Z.d9d<19>Z/d:d<19>Z0d;d<19>Z1d<d<19>Z2d=d<19>Z3d>d<19>Z4d?d<19>Z5d@d<19>Z6dAd<19>Z7dBd<19>Z8dCd<19>Z9dDd<19>Z:dEd<19>Z;dFd<19>Z<dGd<19>Z=dHd<19>Z>dId<19>Z?dJd<19>Z@dKd<19>ZAdLd<19>ZBdMd<19>ZCe<10>rdNd<19>ZDneCZDdOd<19>ZEdPd<19>ZFdQd<19>ZGdRd<19>ZHdSd<19>ZIdS)UrahActs as a proxy for a werkzeug local. Forwards all operations to
a proxied object. The only operations not supported for forwarding
are right handed operands and any kind of assignment.
Example usage::
from werkzeug.local import Local
l = Local()
# these are proxies
request = l('request')
user = l('user')
from werkzeug.local import LocalStack
_response_local = LocalStack()
# this is a proxy
response = _response_local()
Whenever something is bound to l.user / l.request the proxy objects
will forward all operations. If no object is bound a :exc:`RuntimeError`
will be raised.
To create proxies to :class:`Local` or :class:`LocalStack` objects,
call the object as shown above. If you want to have a proxy to an
object looked up by a function, you can (as of Werkzeug 0.6.1) pass
a function to the :class:`LocalProxy` constructor::
session = LocalProxy(lambda: get_current_request().session)
.. versionchanged:: 0.6.1
The class can be instantiated with a callable as well now.
)Z__local<61>__dict__r#<00> __wrapped__NcCs@t<00>|d|<01>t<00>|d|<02>t|<01>r<t|d<03>s<t<00>|d|<01>dS)N<>_LocalProxy__localr#r rH)rr<00>callable<6C>hasattr)rr
rr r r r%szLocalProxy.__init__cCsJt|jd<01>s|<00><01>Syt|j|j<03>Stk
rDtd|j<00><01>YnXdS)z<>Return the current object. This is useful if you want the real
object behind the proxy at a time for performance reasons or because
you want to pass the object into a different context.
r zno object bound to %sN)rKrIr0r#rr,)rr r r <00>_get_current_object-s  zLocalProxy._get_current_objectcCs,y
|<00><00>jStk
r&td<01><01>YnXdS)NrG)rLrGr,r)rr r r rG9s
zLocalProxy.__dict__cCs2y |<00><00>}Wntk
r(d|jjSXt|<01>S)Nz <%s unbound>)rLr,rEr#<00>repr)rr2r r r rF@s
 zLocalProxy.__repr__cCs&y t|<00><01><00>Stk
r dSXdS)NF)<03>boolrLr,)rr r r <00>__bool__Gs zLocalProxy.__bool__cCs*y t|<00><01><00>Stk
r$t|<00>SXdS)N)<04>unicoderLr,rM)rr r r <00> __unicode__Ms zLocalProxy.__unicode__cCs&y t|<00><01><00>Stk
r gSXdS)N)<03>dirrLr,)rr r r <00>__dir__Ss zLocalProxy.__dir__cCs"|dkrt|<00><01><00>St|<00><01>|<01>S)N<> __members__)rRrLr0)rrr r r rYs zLocalProxy.__getattr__cCs||<00><00>|<dS)N)rL)r<00>keyr r r r <00> __setitem__^szLocalProxy.__setitem__cCs|<00><00>|=dS)N)rL)rrUr r r <00> __delitem__aszLocalProxy.__delitem__cCs|<00><00>||<02>S)N)rL)<03>x<>i<>jr r r <00><lambda>e<00>zLocalProxy.<lambda>cCs||<00><00>||<02><dS)N)rL)rrYrZ<00>seqr r r <00> __setslice__gszLocalProxy.__setslice__cCs|<00><00>||<02>=dS)N)rL)rrYrZr r r <00> __delslice__jszLocalProxy.__delslice__cCst|<00><01>||<02>S)N)<02>setattrrL)rX<00>n<>vr r r r[mr\cCst|<00><01>|<01>S)N)<02>delattrrL)rXrar r r r[nr\cCs t|<00><01><00>S)N)<02>strrL)rXr r r r[or\cCs |<00><00>|kS)N)rL)rX<00>or r r r[pr\cCs |<00><00>|kS)N)rL)rXrer r r r[qr\cCs |<00><00>|kS)N)rL)rXrer r r r[rr\cCs |<00><00>|kS)N)rL)rXrer r r r[sr\cCs |<00><00>|kS)N)rL)rXrer r r r[tr\cCs |<00><00>|kS)N)rL)rXrer r r r[ur\cCst|<00><01>|<01>S)N)<02>cmprL)rXrer r r r[vr\cCs t|<00><01><00>S)N)<02>hashrL)rXr r r r[wr\cOs|<00><00>||<02>S)N)rL)rX<00>a<>kwr r r r[xr\cCs t|<00><01><00>S)N)r5rL)rXr r r r[yr\cCs |<00><00>|S)N)rL)rXrYr r r r[zr\cCs t|<00><01><00>S)N)rrL)rXr r r r[{r\cCs ||<00><00>kS)N)rL)rXrYr r r r[|r\cCs |<00><00>|S)N)rL)rXrer r r r[}r\cCs |<00><00>|S)N)rL)rXrer r r r[~r\cCs |<00><00>|S)N)rL)rXrer r r r[r\cCs |<00><00>|S)N)rL)rXrer r r r[<00>r\cCs |<00><00>|S)N)rL)rXrer r r r[<00>r\cCs|<00><00><00>|<01>S)N)rL<00>
__divmod__)rXrer r r r[<00>r\cCs |<00><00>|S)N)rL)rXrer r r r[<00>r\cCs |<00><00>|>S)N)rL)rXrer r r r[<00>r\cCs |<00><00>|?S)N)rL)rXrer r r r[<00>r\cCs |<00><00>|@S)N)rL)rXrer r r r[<00>r\cCs |<00><00>|AS)N)rL)rXrer r r r[<00>r\cCs |<00><00>|BS)N)rL)rXrer r r r[<00>r\cCs|<00><00><00>|<01>S)N)rL<00>__div__)rXrer r r r[<00>r\cCs|<00><00><00>|<01>S)N)rL<00> __truediv__)rXrer r r r[<00>r\cCs
|<00><00> S)N)rL)rXr r r r[<00>r\cCs
|<00><00>
S)N)rL)rXr r r r[<00>r\cCs t|<00><01><00>S)N)<02>absrL)rXr r r r[<00>r\cCs
|<00><00>S)N)rL)rXr r r r[<00>r\cCs t|<00><01><00>S)N)<02>complexrL)rXr r r r[<00>r\cCs t|<00><01><00>S)N)<02>intrL)rXr r r r[<00>r\cCs t|<00><01><00>S)N)<02>longrL)rXr r r r[<00>r\cCs t|<00><01><00>S)N)<02>floatrL)rXr r r r[<00>r\cCs t|<00><01><00>S)N)<02>octrL)rXr r r r[<00>r\cCs t|<00><01><00>S)N)<02>hexrL)rXr r r r[<00>r\cCs |<00><00><00><01>S)N)rL<00> __index__)rXr r r r[<00>r\cCs|<00><00><00>||<01>S)N)rL<00>
__coerce__)rXrer r r r[<00>r\cCs |<00><00><00><01>S)N)rL<00> __enter__)rXr r r r[<00>r\cOs|<00><00>j||<02>S)N)rL<00>__exit__)rXrhrir r r r[<00>r\cCs ||<00><00>S)N)rL)rXrer r r r[<00>r\cCs ||<00><00>S)N)rL)rXrer r r r[<00>r\cCs ||<00><00>S)N)rL)rXrer r r r[<00>r\cCs ||<00><00>S)N)rL)rXrer r r r[<00>r\cCs|<00><00><00>|<01>S)N)rL<00> __rtruediv__)rXrer r r r[<00>r\cCs ||<00><00>S)N)rL)rXrer r r r[<00>r\cCs ||<00><00>S)N)rL)rXrer r r r[<00>r\cCs|<00><00><00>|<01>S)N)rL<00> __rdivmod__)rXrer r r r[<00>r\cCst<00>|<00><01><00>S)N)<02>copyrL)rXr r r r[<00>r\cCst<00>|<00><02>|<01>S)N)rz<00>deepcopyrL)rX<00>memor r r r[<00>r\)N)Jr#r$r%r7r&rrLr8rGrFrOrQrSrrVrWrZ __getslice__r^r_rr"<00>__str__<5F>__lt__<5F>__le__<5F>__eq__<5F>__ne__<5F>__gt__<5F>__ge__Z__cmp__<5F>__hash__r<00>__len__<5F> __getitem__r<00> __contains__<5F>__add__<5F>__sub__<5F>__mul__<5F> __floordiv__<5F>__mod__rj<00>__pow__<5F>
__lshift__<EFBFBD>
__rshift__<EFBFBD>__and__<5F>__xor__<5F>__or__rkrl<00>__neg__<5F>__pos__<5F>__abs__<5F>
__invert__<EFBFBD> __complex__<5F>__int__Z__long__<5F> __float__Z__oct__Z__hex__rtrurvrw<00>__radd__<5F>__rsub__<5F>__rmul__Z__rdiv__rx<00> __rfloordiv__<5F>__rmod__ry<00>__copy__<5F> __deepcopy__r r r r r<00>s<>#
 
r)r7rz<00> functoolsr<00>_compatrrZwsgirZgreenletrr<00> ImportError<6F>thread<61>_threadr rrr'r9rr r r r <00><module>
s$    &SP