class documentation

class LocalProxy:

View In Hierarchy

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
Changed in version 2.0: Updated proxied attributes and methods to reflect the current data model.
Changed in version 0.6.1: The class can be instantiated with a callable.
Parameters
localThe Local or callable that provides the proxied object.
nameThe 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.
def __init__(self, local, name=None):

Undocumented

Parameters
local:t.Union[Local, t.Callable[[], t.Any]]Undocumented
name:t.Optional[str]Undocumented
__abs__ =

Undocumented

__add__ =

Undocumented

__aenter__ =

Undocumented

__aexit__ =

Undocumented

__aiter__ =

Undocumented

__and__ =

Undocumented

__anext__ =

Undocumented

__await__ =

Undocumented

__bool__ =

Undocumented

__bytes__ =

Undocumented

__call__ =

Undocumented

__ceil__ =

Undocumented

__class__ =

Undocumented

__complex__ =

Undocumented

__contains__ =

Undocumented

__copy__ =

Undocumented

__deepcopy__ =

Undocumented

__delattr__ =

Undocumented

__delitem__ =

Undocumented

__dir__ =

Undocumented

__divmod__ =

Undocumented

__doc__ =

Undocumented

__enter__ =

Undocumented

__eq__ =

Undocumented

__exit__ =

Undocumented

__float__ =

Undocumented

__floor__ =

Undocumented

__floordiv__ =

Undocumented

__format__ =

Undocumented

__ge__ =

Undocumented

__getattr__ =

Undocumented

__getitem__ =

Undocumented

__gt__ =

Undocumented

__hash__ =

Undocumented

__iadd__ =

Undocumented

__iand__ =

Undocumented

__ifloordiv__ =

Undocumented

__ilshift__ =

Undocumented

__imatmul__ =

Undocumented

__imod__ =

Undocumented

__imul__ =

Undocumented

__index__ =

Undocumented

__instancecheck__ =

Undocumented

__int__ =

Undocumented

__invert__ =

Undocumented

__ior__ =

Undocumented

__ipow__ =

Undocumented

__irshift__ =

Undocumented

__isub__ =

Undocumented

__iter__ =

Undocumented

__itruediv__ =

Undocumented

__ixor__ =

Undocumented

__le__ =

Undocumented

__len__ =

Undocumented

__length_hint__ =

Undocumented

__lshift__ =

Undocumented

__lt__ =

Undocumented

__matmul__ =

Undocumented

__mod__ =

Undocumented

__mul__ =

Undocumented

__ne__ =

Undocumented

__neg__ =

Undocumented

__next__ =

Undocumented

__or__ =

Undocumented

__pos__ =

Undocumented

__pow__ =

Undocumented

__radd__ =

Undocumented

__rand__ =

Undocumented

__rdivmod__ =

Undocumented

__repr__ =

Undocumented

__reversed__ =

Undocumented

__rfloordiv__ =

Undocumented

__rlshift__ =

Undocumented

__rmatmul__ =

Undocumented

__rmod__ =

Undocumented

__rmul__ =

Undocumented

__ror__ =

Undocumented

__round__ =

Undocumented

__rpow__ =

Undocumented

__rrshift__ =

Undocumented

__rshift__ =

Undocumented

__rsub__ =

Undocumented

__rtruediv__ =

Undocumented

__rxor__ =

Undocumented

__setattr__ =

Undocumented

__setitem__ =

Undocumented

__slots__: tuple[str, ...] =

Undocumented

__str__ =

Undocumented

__sub__ =

Undocumented

__subclasscheck__ =

Undocumented

__truediv__ =

Undocumented

__trunc__ =

Undocumented

__xor__ =

Undocumented

def _get_current_object(self):
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.
Returns
t.AnyUndocumented