Merge "refactor the getid method base.py"
This commit is contained in:
@@ -41,15 +41,10 @@ def getid(obj):
|
|||||||
Abstracts the common pattern of allowing both an object or an object's ID
|
Abstracts the common pattern of allowing both an object or an object's ID
|
||||||
(UUID) as a parameter when dealing with relationships.
|
(UUID) as a parameter when dealing with relationships.
|
||||||
"""
|
"""
|
||||||
try:
|
if getattr(obj, 'uuid', None):
|
||||||
if obj.uuid:
|
return obj.uuid
|
||||||
return obj.uuid
|
else:
|
||||||
except AttributeError:
|
return getattr(obj, 'id', obj)
|
||||||
pass
|
|
||||||
try:
|
|
||||||
return obj.id
|
|
||||||
except AttributeError:
|
|
||||||
return obj
|
|
||||||
|
|
||||||
|
|
||||||
# TODO(aababilov): call run_hooks() in HookableMixin's child classes
|
# TODO(aababilov): call run_hooks() in HookableMixin's child classes
|
||||||
|
@@ -53,10 +53,7 @@ def getid(obj):
|
|||||||
Abstracts the common pattern of allowing both an object or an object's ID
|
Abstracts the common pattern of allowing both an object or an object's ID
|
||||||
as a parameter when dealing with relationships.
|
as a parameter when dealing with relationships.
|
||||||
"""
|
"""
|
||||||
try:
|
return getattr(obj, 'id', obj)
|
||||||
return obj.id
|
|
||||||
except AttributeError:
|
|
||||||
return obj
|
|
||||||
|
|
||||||
|
|
||||||
class Manager(common_base.HookableMixin):
|
class Manager(common_base.HookableMixin):
|
||||||
|
Reference in New Issue
Block a user