Refactor the getid method base.py

Refer to a merged commit.
https://review.openstack.org/#/c/588983/

Change-Id: I37d9f1f0a6b4e0b6493dd12e5599972d1c98f158
This commit is contained in:
wanghui
2018-11-08 20:32:57 +08:00
parent d41daca59b
commit 5f66ec2c35

View File

@@ -32,10 +32,7 @@ def getid(obj):
Abstracts the common pattern of allowing both an object or an
object's ID (UUID) as a parameter when dealing with relationships.
"""
try:
return obj.id
except AttributeError:
return obj
return getattr(obj, 'id', obj)
class Manager(object):