Revert "Add properties for id attributes"

This reverts commit 78644789ce.

Change-Id: I92257b7bade0e2e5c4e1b387b437d929afc1a4db
Related-Bug: #1532427
This commit is contained in:
Davanum Srinivas (dims) 2016-01-09 12:04:52 +00:00
parent 78644789ce
commit 04e40fa8d4
2 changed files with 0 additions and 56 deletions

View File

@ -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

View File

@ -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)