Refactor the getid method base.py

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

Change-Id: I9765543c288370cfcdaaa930b2839e28b51a9380
This commit is contained in:
wanghui 2018-11-09 20:09:58 +08:00
parent 946ef06dc6
commit 94f6864bf0
1 changed files with 1 additions and 4 deletions

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