Merge "Remove unused methods set_ctx and get_ctx"
This commit is contained in:
commit
f5a2f1585c
@ -13,7 +13,6 @@
|
|||||||
import functools
|
import functools
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
from eventlet.green import threading
|
|
||||||
from oslo_context import context
|
from oslo_context import context
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
import six
|
import six
|
||||||
@ -170,25 +169,6 @@ def get_admin_context(show_deleted=False, all_projects=False):
|
|||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
_CTX_STORE = threading.local()
|
|
||||||
_CTX_KEY = 'current_ctx'
|
|
||||||
|
|
||||||
|
|
||||||
def has_ctx():
|
|
||||||
return hasattr(_CTX_STORE, _CTX_KEY)
|
|
||||||
|
|
||||||
|
|
||||||
def set_ctx(new_ctx):
|
|
||||||
if not new_ctx and has_ctx():
|
|
||||||
delattr(_CTX_STORE, _CTX_KEY)
|
|
||||||
if hasattr(context._request_store, 'context'):
|
|
||||||
delattr(context._request_store, 'context')
|
|
||||||
|
|
||||||
if new_ctx:
|
|
||||||
setattr(_CTX_STORE, _CTX_KEY, new_ctx)
|
|
||||||
setattr(context._request_store, 'context', new_ctx)
|
|
||||||
|
|
||||||
|
|
||||||
def set_context(func):
|
def set_context(func):
|
||||||
@functools.wraps(func)
|
@functools.wraps(func)
|
||||||
def handler(self, ctx):
|
def handler(self, ctx):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user