diff options
author | Davanum Srinivas (dims) <davanum@gmail.com> | 2016-01-09 12:04:52 +0000 |
---|---|---|
committer | Davanum Srinivas (dims) <davanum@gmail.com> | 2016-01-09 12:04:52 +0000 |
commit | 04e40fa8d4a94c9dbc0b9d8ff6aef735c095f603 (patch) | |
tree | eb20cf0dd85cc784c2e02b2fd430037e01899924 | |
parent | 78644789ce911df77dfed85a5b26d781386f9717 (diff) | |
download | oslo-context-04e40fa8d4a94c9dbc0b9d8ff6aef735c095f603.tar.gz |
Revert "Add properties for id attributes"1.0.1
This reverts commit 78644789ce911df77dfed85a5b26d781386f9717.
Change-Id: I92257b7bade0e2e5c4e1b387b437d929afc1a4db
Related-Bug: #1532427
-rw-r--r-- | oslo_context/context.py | 27 | ||||
-rw-r--r-- | oslo_context/tests/test_context.py | 29 |
2 files changed, 0 insertions, 56 deletions
diff --git a/oslo_context/context.py b/oslo_context/context.py index c474492..5d06cb8 100644 --- a/oslo_context/context.py +++ b/oslo_context/context.py @@ -32,23 +32,6 @@ def generate_request_id(): return b'req-' + str(uuid.uuid4()).encode('ascii') -class _new_prop(object): - """Create a new property that refers to an old one. - - For backwards compatibility reasons we need to maintain some attributes of - context that should be deprecated. Create a property with a name that - points to an otherwise public attribute. - """ - def __init__(self, old_name): - self.old_name = old_name - - def __get__(self, obj, objtype): - return getattr(obj, self.old_name) - - def __set__(self, obj, val): - return setattr(obj, self.old_name, val) - - class RequestContext(object): """Helper class to represent useful information about a request context. @@ -84,16 +67,6 @@ class RequestContext(object): if overwrite or not get_current(): self.update_store() - # NOTE(jamielennox): for now we store under the old name and reference via - # the new name. This is currently easier than changing the __init__ - # arguments. In future this should be swapped and the non-_id suffixed - # attributes deprecated. - user_id = _new_prop('user') - project_id = _new_prop('tenant') - domain_id = _new_prop('domain') - user_domain_id = _new_prop('user_domain') - project_domain_id = _new_prop('project_domain') - def update_store(self): _request_store.context = self diff --git a/oslo_context/tests/test_context.py b/oslo_context/tests/test_context.py index e1ae386..9e6b252 100644 --- a/oslo_context/tests/test_context.py +++ b/oslo_context/tests/test_context.py @@ -13,8 +13,6 @@ # License for the specific language governing permissions and limitations # under the License. -import uuid - from oslotest import base as test_base from oslo_context import context @@ -94,30 +92,3 @@ class ContextTest(test_base.BaseTestCase): self.assertFalse(context.is_user_context(ctx)) ctx = context.RequestContext(is_admin=False) self.assertTrue(context.is_user_context(ctx)) - - def test_aliased_props(self): - user = uuid.uuid4().hex - tenant = uuid.uuid4().hex - domain = uuid.uuid4().hex - user_domain = uuid.uuid4().hex - project_domain = uuid.uuid4().hex - - ctx = context.RequestContext(user=user, - tenant=tenant, - domain=domain, - user_domain=user_domain, - project_domain=project_domain) - - # original attributes - self.assertEqual(user, ctx.user) - self.assertEqual(tenant, ctx.tenant) - self.assertEqual(domain, ctx.domain) - self.assertEqual(user_domain, ctx.user_domain) - self.assertEqual(project_domain, ctx.project_domain) - - # aliased properties - self.assertEqual(user, ctx.user_id) - self.assertEqual(tenant, ctx.project_id) - self.assertEqual(domain, ctx.domain_id) - self.assertEqual(user_domain, ctx.user_domain_id) - self.assertEqual(project_domain, ctx.project_domain_id) |