Refactor the getid method base.py

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

Change-Id: Ied829d0a4f8bba79920320e028d37db7ba23491b
This commit is contained in:
wanghui 2018-11-09 20:11:28 +08:00
parent 2056f16e0d
commit f56ad38b83

View File

@ -31,10 +31,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):