class LocalProxy:
A proxy to the object bound to a Local
. All operations
on the proxy are forwarded to the bound object. If no object is
bound, a RuntimeError
is raised.
from werkzeug.local import Local l = Local() # a proxy to whatever l.user is set to user = l("user") from werkzeug.local import LocalStack _request_stack = LocalStack() # a proxy to _request_stack.top request = _request_stack() # a proxy to the session attribute of the request proxy session = LocalProxy(lambda: request.session)
__repr__ and __class__ are forwarded, so repr(x) and isinstance(x, cls) will look like the proxied object. Use issubclass(type(x), LocalProxy) to check if an object is a proxy.
repr(user) # <User admin> isinstance(user, User) # True issubclass(type(user), LocalProxy) # True
Parameters | |
local | The Local or callable that provides the
proxied object. |
name | The attribute name to look up on a Local . Not
used if a callable is given. |
Method | __init__ |
Undocumented |
Class Variable | __abs__ |
Undocumented |
Class Variable | __add__ |
Undocumented |
Class Variable | __aenter__ |
Undocumented |
Class Variable | __aexit__ |
Undocumented |
Class Variable | __aiter__ |
Undocumented |
Class Variable | __and__ |
Undocumented |
Class Variable | __anext__ |
Undocumented |
Class Variable | __await__ |
Undocumented |
Class Variable | __bool__ |
Undocumented |
Class Variable | __bytes__ |
Undocumented |
Class Variable | __call__ |
Undocumented |
Class Variable | __ceil__ |
Undocumented |
Class Variable | __class__ |
Undocumented |
Class Variable | __complex__ |
Undocumented |
Class Variable | __contains__ |
Undocumented |
Class Variable | __copy__ |
Undocumented |
Class Variable | __deepcopy__ |
Undocumented |
Class Variable | __delattr__ |
Undocumented |
Class Variable | __delitem__ |
Undocumented |
Class Variable | __dir__ |
Undocumented |
Class Variable | __divmod__ |
Undocumented |
Class Variable | __doc__ |
Undocumented |
Class Variable | __enter__ |
Undocumented |
Class Variable | __eq__ |
Undocumented |
Class Variable | __exit__ |
Undocumented |
Class Variable | __float__ |
Undocumented |
Class Variable | __floor__ |
Undocumented |
Class Variable | __floordiv__ |
Undocumented |
Class Variable | __format__ |
Undocumented |
Class Variable | __ge__ |
Undocumented |
Class Variable | __getattr__ |
Undocumented |
Class Variable | __getitem__ |
Undocumented |
Class Variable | __gt__ |
Undocumented |
Class Variable | __hash__ |
Undocumented |
Class Variable | __iadd__ |
Undocumented |
Class Variable | __iand__ |
Undocumented |
Class Variable | __ifloordiv__ |
Undocumented |
Class Variable | __ilshift__ |
Undocumented |
Class Variable | __imatmul__ |
Undocumented |
Class Variable | __imod__ |
Undocumented |
Class Variable | __imul__ |
Undocumented |
Class Variable | __index__ |
Undocumented |
Class Variable | __instancecheck__ |
Undocumented |
Class Variable | __int__ |
Undocumented |
Class Variable | __invert__ |
Undocumented |
Class Variable | __ior__ |
Undocumented |
Class Variable | __ipow__ |
Undocumented |
Class Variable | __irshift__ |
Undocumented |
Class Variable | __isub__ |
Undocumented |
Class Variable | __iter__ |
Undocumented |
Class Variable | __itruediv__ |
Undocumented |
Class Variable | __ixor__ |
Undocumented |
Class Variable | __le__ |
Undocumented |
Class Variable | __len__ |
Undocumented |
Class Variable | __length_hint__ |
Undocumented |
Class Variable | __lshift__ |
Undocumented |
Class Variable | __lt__ |
Undocumented |
Class Variable | __matmul__ |
Undocumented |
Class Variable | __mod__ |
Undocumented |
Class Variable | __mul__ |
Undocumented |
Class Variable | __ne__ |
Undocumented |
Class Variable | __neg__ |
Undocumented |
Class Variable | __next__ |
Undocumented |
Class Variable | __or__ |
Undocumented |
Class Variable | __pos__ |
Undocumented |
Class Variable | __pow__ |
Undocumented |
Class Variable | __radd__ |
Undocumented |
Class Variable | __rand__ |
Undocumented |
Class Variable | __rdivmod__ |
Undocumented |
Class Variable | __repr__ |
Undocumented |
Class Variable | __reversed__ |
Undocumented |
Class Variable | __rfloordiv__ |
Undocumented |
Class Variable | __rlshift__ |
Undocumented |
Class Variable | __rmatmul__ |
Undocumented |
Class Variable | __rmod__ |
Undocumented |
Class Variable | __rmul__ |
Undocumented |
Class Variable | __ror__ |
Undocumented |
Class Variable | __round__ |
Undocumented |
Class Variable | __rpow__ |
Undocumented |
Class Variable | __rrshift__ |
Undocumented |
Class Variable | __rshift__ |
Undocumented |
Class Variable | __rsub__ |
Undocumented |
Class Variable | __rtruediv__ |
Undocumented |
Class Variable | __rxor__ |
Undocumented |
Class Variable | __setattr__ |
Undocumented |
Class Variable | __setitem__ |
Undocumented |
Class Variable | __slots__ |
Undocumented |
Class Variable | __str__ |
Undocumented |
Class Variable | __sub__ |
Undocumented |
Class Variable | __subclasscheck__ |
Undocumented |
Class Variable | __truediv__ |
Undocumented |
Class Variable | __trunc__ |
Undocumented |
Class Variable | __xor__ |
Undocumented |
Method | _get_current_object |
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. |
Undocumented
Parameters | |
local:t.Union[ | Undocumented |
name:t.Optional[ | Undocumented |