Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Commit

Permalink
Switch to warnings module instead of versionutils
Browse files Browse the repository at this point in the history
versionutils.py is no longer in oslo-incubator. So we can
either use versionutils from oslo_log or debtcollector instead.
However, oslo.messaging does not use oslo.log currently and we
should not be adding yet another library as a dependency here,
so we should just use the base python warnings library for
our limited use of deprecated() method.

Change-Id: Ib8a487051c894fa4828da65d4890b7a4f57f1d12
  • Loading branch information
dims authored and thomasgoirand committed Jul 30, 2015
1 parent ee8037f commit 5b15364
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 275 deletions.
7 changes: 0 additions & 7 deletions openstack-common.conf

This file was deleted.

26 changes: 20 additions & 6 deletions oslo_messaging/localcontext.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,31 @@
'_clear_local_context',
]

from functools import wraps
import threading
import uuid

from oslo_messaging.openstack.common import versionutils
import warnings


def _deprecated(as_of=None, in_favor_of=None):
def __inner(func):
@wraps(func)
def __wrapper(*args, **kwargs):
replaced_by = (' Please use %s instead.'
% in_favor_of) if in_favor_of else ''
warnings.warn('%s has been deprecated in %s and will be '
'removed in the next release.%s' %
(func.__name__, as_of, replaced_by))
return func(*args, **kwargs)
return __wrapper
return __inner
_VERSION = '1.8.0'

_KEY = '_%s_%s' % (__name__.replace('.', '_'), uuid.uuid4().hex)
_STORE = threading.local()


@versionutils.deprecated(as_of=versionutils.deprecated.KILO,
in_favor_of='oslo_context.context.get_current')
@_deprecated(as_of=_VERSION, in_favor_of='oslo_context.context.get_current')
def get_local_context(ctxt):
"""Retrieve the RPC endpoint request context for the current thread.
Expand All @@ -47,7 +61,7 @@ def get_local_context(ctxt):
return getattr(_STORE, _KEY, None)


@versionutils.deprecated(as_of=versionutils.deprecated.KILO)
@_deprecated(as_of=_VERSION)
def set_local_context(ctxt):
_set_local_context(ctxt)

Expand All @@ -61,7 +75,7 @@ def _set_local_context(ctxt):
setattr(_STORE, _KEY, ctxt)


@versionutils.deprecated(as_of=versionutils.deprecated.KILO)
@_deprecated(as_of=_VERSION)
def clear_local_context():
_clear_local_context()

Expand Down
262 changes: 0 additions & 262 deletions oslo_messaging/openstack/common/versionutils.py

This file was deleted.

0 comments on commit 5b15364

Please sign in to comment.