| | |
| | | |
| | | from pyramid.registry import global_registry |
| | | |
| | | |
| | | class ThreadLocalManager(threading.local): |
| | | def __init__(self, default=None): |
| | | # http://code.google.com/p/google-app-engine-django/issues/detail?id=119 |
| | |
| | | def push(self, info): |
| | | self.stack.append(info) |
| | | |
| | | set = push # b/c |
| | | set = push # b/c |
| | | |
| | | def pop(self): |
| | | if self.stack: |
| | |
| | | def clear(self): |
| | | self.stack[:] = [] |
| | | |
| | | |
| | | def defaults(): |
| | | return {'request': None, 'registry': global_registry} |
| | | |
| | | |
| | | manager = ThreadLocalManager(default=defaults) |
| | | |
| | | |
| | | def get_current_request(): |
| | | """ |
| | |
| | | """ |
| | | return manager.get()['request'] |
| | | |
| | | def get_current_registry(context=None): # context required by getSiteManager API |
| | | |
| | | def get_current_registry( |
| | | context=None |
| | | ): # context required by getSiteManager API |
| | | """ |
| | | Return the currently active :term:`application registry` or the |
| | | global application registry if no request is currently active. |
| | |
| | | """ |
| | | return manager.get()['registry'] |
| | | |
| | | |
| | | class RequestContext(object): |
| | | def __init__(self, request): |
| | | self.request = request |