from __future__ import absolute_import from threading import local class TransactionContext(object): def __init__(self, stack, context): self.stack = stack self.context = context def __enter__(self): self.stack.push(self.context) return self def __exit__(self, *exc_info): self.stack.pop(self.context) class TransactionStack(local): def __init__(self): self.stack = [] def __len__(self): return len(self.stack) def __iter__(self): return iter(self.stack) def __call__(self, context): return TransactionContext(self, context) def clear(self): self.stack = [] def peek(self): try: return self.stack[-1] except IndexError: return None def push(self, context): self.stack.append(context) return context def pop(self, context=None): if context is None: return self.stack.pop() while self.stack: if self.stack.pop() is context: return context
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
__pycache__ | Folder | 0755 |
|
|
serializer | Folder | 0755 |
|
|
__init__.py | File | 3.14 KB | 0644 |
|
basic.py | File | 2.39 KB | 0644 |
|
compat.py | File | 5.54 KB | 0644 |
|
conf.py | File | 2.29 KB | 0644 |
|
encoding.py | File | 3.23 KB | 0644 |
|
http.py | File | 1.95 KB | 0644 |
|
imports.py | File | 404 B | 0644 |
|
json.py | File | 2.91 KB | 0644 |
|
ssl_match_hostname.py | File | 3.51 KB | 0644 |
|
stacks.py | File | 9.8 KB | 0644 |
|
testutils.py | File | 697 B | 0644 |
|
transaction.py | File | 1.06 KB | 0644 |
|
urlparse.py | File | 476 B | 0644 |
|
wsgi.py | File | 3.64 KB | 0644 |
|