本文整理汇总了Python中framework.guid.model.Guid.generate方法的典型用法代码示例。如果您正苦于以下问题:Python Guid.generate方法的具体用法?Python Guid.generate怎么用?Python Guid.generate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类framework.guid.model.Guid
的用法示例。
在下文中一共展示了Guid.generate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_guid
# 需要导入模块: from framework.guid.model import Guid [as 别名]
# 或者: from framework.guid.model.Guid import generate [as 别名]
def get_guid(self, create=False):
"""Attempt to find a Guid that points to this object.
One will be created if requested.
:rtype: Guid
"""
try:
# Note sometimes multiple GUIDs can exist for
# a single object. Just go with the first one
return Guid.find(Q('referent', 'eq', self))[0]
except IndexError:
if not create:
return None
return Guid.generate(self)
示例2: get_guid
# 需要导入模块: from framework.guid.model import Guid [as 别名]
# 或者: from framework.guid.model.Guid import generate [as 别名]
def get_guid(self, create=False):
"""Attempt to find a Guid that points to this object.
One will be created if requested.
:param Boolean create: Should we generate a GUID if there isn't one? Default: False
:rtype: Guid or None
"""
try:
# Note sometimes multiple GUIDs can exist for
# a single object. Just go with the first one
return Guid.find(Q("referent", "eq", self))[0]
except IndexError:
if not create:
return None
return Guid.generate(self)