def getObjectIdByName(self, object_name, object_subname=None):
andList = [ md.InventoryObjects.c.class_id == self._classId, md.InventoryObjects.c.object_name == object_name ]
if not object_subname is None:
andList.append(md.InventoryObjects.c.object_subname == object_subname)
object_id = None
i = 0
for row in self._connection.execute(md.InventoryObjects.select().where(and_(*andList))):
i = i + 1
object_id = row["object_id"]
if i > 1:
raise LookupException("Too many objects were found")
if i == 0:
raise EmptyLookupException("No objects were found")
return object_id
评论列表
文章目录