From e9ce471c277995ff53032951fe43d5b08381dad4 Mon Sep 17 00:00:00 2001 From: Ronald Bradford Date: Fri, 18 Mar 2016 11:16:50 -0400 Subject: [PATCH] Remove use of Oslo Incubator local Remove last use of Oslo Incubator and cleanup docs. Change-Id: I56c8dbbc72733446f970a7f6a4a651d11422de8e --- HACKING.rst | 14 -------- openstack-common.conf | 3 -- poppy/openstack/common/__init__.py | 17 ---------- poppy/openstack/common/local.py | 45 -------------------------- poppy/transport/pecan/hooks/context.py | 11 ++++--- tox.ini | 2 +- 6 files changed, 7 insertions(+), 85 deletions(-) delete mode 100644 openstack-common.conf delete mode 100644 poppy/openstack/common/__init__.py delete mode 100644 poppy/openstack/common/local.py diff --git a/HACKING.rst b/HACKING.rst index c766e970..8d57d54a 100644 --- a/HACKING.rst +++ b/HACKING.rst @@ -254,20 +254,6 @@ without the patch and passes with the patch. NOTE: 100% coverage is required -openstack-common ----------------- - -A number of modules from openstack-common are imported into the project. - -These modules are "incubating" in openstack-common and are kept in sync -with the help of openstack-common's update.py script. See: - - http://wiki.openstack.org/CommonLibrary#Incubation - -The copy of the code should never be directly modified here. Please -always update openstack-common first and then run the script to copy -the changes across. - Logging ------- diff --git a/openstack-common.conf b/openstack-common.conf deleted file mode 100644 index 37b53e02..00000000 --- a/openstack-common.conf +++ /dev/null @@ -1,3 +0,0 @@ -[DEFAULT] -base=poppy -module=local diff --git a/poppy/openstack/common/__init__.py b/poppy/openstack/common/__init__.py deleted file mode 100644 index d1223eaf..00000000 --- a/poppy/openstack/common/__init__.py +++ /dev/null @@ -1,17 +0,0 @@ -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import six - - -six.add_move(six.MovedModule('mox', 'mox', 'mox3.mox')) diff --git a/poppy/openstack/common/local.py b/poppy/openstack/common/local.py deleted file mode 100644 index 0819d5b9..00000000 --- a/poppy/openstack/common/local.py +++ /dev/null @@ -1,45 +0,0 @@ -# Copyright 2011 OpenStack Foundation. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -"""Local storage of variables using weak references""" - -import threading -import weakref - - -class WeakLocal(threading.local): - def __getattribute__(self, attr): - rval = super(WeakLocal, self).__getattribute__(attr) - if rval: - # NOTE(mikal): this bit is confusing. What is stored is a weak - # reference, not the value itself. We therefore need to lookup - # the weak reference and return the inner value here. - rval = rval() - return rval - - def __setattr__(self, attr, value): - value = weakref.ref(value) - return super(WeakLocal, self).__setattr__(attr, value) - - -# NOTE(mikal): the name "store" should be deprecated in the future -store = WeakLocal() - -# A "weak" store uses weak references and allows an object to fall out of scope -# when it falls out of scope in the code that uses the thread local storage. A -# "strong" store will hold a reference to the object so that it never falls out -# of scope. -weak_store = WeakLocal() -strong_store = threading.local() diff --git a/poppy/transport/pecan/hooks/context.py b/poppy/transport/pecan/hooks/context.py index fcda8114..1e5cb1ca 100644 --- a/poppy/transport/pecan/hooks/context.py +++ b/poppy/transport/pecan/hooks/context.py @@ -17,8 +17,9 @@ from oslo_config import cfg from oslo_context import context import pecan from pecan import hooks +import threading -from poppy.openstack.common import local +_local_store = threading.local() class PoppyRequestContext(context.RequestContext): @@ -56,13 +57,13 @@ class ContextHook(hooks.PecanHook): request_context = PoppyRequestContext(**context_kwargs) state.request.context = request_context - local.store.context = request_context + _local_store.context = request_context '''Attach tenant_id as a member variable project_id to controller.''' - state.controller.__self__.project_id = getattr(local.store.context, + state.controller.__self__.project_id = getattr(_local_store.context, "tenant", None) - state.controller.__self__.base_url = getattr(local.store.context, + state.controller.__self__.base_url = getattr(_local_store.context, "base_url", None) '''Attach auth_token as a member variable project_id to controller.''' - state.controller.__self__.auth_token = getattr(local.store.context, + state.controller.__self__.auth_token = getattr(_local_store.context, "auth_token", None) diff --git a/tox.ini b/tox.ini index 2ad3b6d2..e400d93a 100644 --- a/tox.ini +++ b/tox.ini @@ -56,7 +56,7 @@ commands = {posargs} [flake8] builtins = __CDN_SETUP__ -exclude = build,.venv*,venv*,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*.egg,.update-venv +exclude = build,.venv*,venv*,.git,.tox,dist,doc,*lib/python*,*.egg,.update-venv [hacking] import_exceptions = poppy.common._i18n._