我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用werkzeug.local.LocalStack()。
def release_local(local): """Releases 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 """ local.__release_local__()
def test_custom_idents(self): ident = 0 loc = local.Local() stack = local.LocalStack() mgr = local.LocalManager([loc, stack], ident_func=lambda: ident) loc.foo = 42 stack.push({'foo': 42}) ident = 1 loc.foo = 23 stack.push({'foo': 23}) ident = 0 assert loc.foo == 42 assert stack.top['foo'] == 42 stack.pop() assert stack.top is None ident = 1 assert loc.foo == 23 assert stack.top['foo'] == 23 stack.pop() assert stack.top is None