本文整理汇总了Python中tornado.util.ObjectDict.lattice_id方法的典型用法代码示例。如果您正苦于以下问题:Python ObjectDict.lattice_id方法的具体用法?Python ObjectDict.lattice_id怎么用?Python ObjectDict.lattice_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tornado.util.ObjectDict
的用法示例。
在下文中一共展示了ObjectDict.lattice_id方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _form_upload_post
# 需要导入模块: from tornado.util import ObjectDict [as 别名]
# 或者: from tornado.util.ObjectDict import lattice_id [as 别名]
#.........这里部分代码省略.........
file_content[file_id] = data_file.body
# check that all the data files specified by the
# lattice have been submitted as attachments
for filename in lattice.files:
for f in ctx.lattice.files:
if f.filename == filename:
break
else:
ctx.errors.data_file = "Missing data file: " + filename
send_status(400, ctx)
return
attachment_path = self.settings.get("attachment_path", "")
if len(attachment_path) == 0:
LOGGER.warn("setting 'attachment_path' not found")
ctx.errors._global = "Attachment directory not specified"
send_status(500, ctx)
return
if not os.path.isdir(attachment_path):
LOGGER.error("attachment path '%s' not found", attachment_path)
ctx.errors._global = "Attachment directory not found"
send_status(500, ctx)
return
try:
yield data.validate_lattice(ctx.lattice)
except Exception as e:
LOGGER.error("lattice validation error: %s", e)
ctx.errors._global = "Lattice validation error"
send_status(500, ctx)
return
lattice_elements = []
for idx, element in enumerate(lattice.elements):
lattice_element = ObjectDict()
lattice_element.lattice_id = ctx.lattice._id
lattice_element.order = idx+1
lattice_element.name = element.name
lattice_element.type = element.etype
lattice_element.length = element.length
lattice_element.position = element.position
lattice_element.properties = []
lattice_element.properties.append(dict(
name="ITYPE",
value=element.itype
))
lattice_element.properties.append(dict(
name="STEPS",
value=element.steps
))
for field in element.fields:
lattice_element.properties.append(dict(
name = field.name,
unit = field.unit,
value = element.getfield(field.name)
))
try:
yield data.validate_lattice_element(lattice_element)
except Exception as e:
LOGGER.error("lattice element validation error: %s", e)
ctx.errors._global = "Lattice element validation error"
send_status(500, ctx)
return
lattice_elements.append(lattice_element)
try:
lattice_id = yield data.insert_lattice(ctx.lattice, validate=False)
except Exception as e:
LOGGER.error("lattice database insert error: %s", e)
ctx.errors._global = "Lattice database insert error"
send_status(500, ctx)
return
try:
for lattice_element in lattice_elements:
lattice_element.lattice_id = lattice_id
data.insert_lattice_element(lattice_element, validate=False)
except Exception as e:
LOGGER.error("lattice element database insert error: %s", e)
ctx.errors._global = "Lattice element database insert error"
# Rollback?
send_status(500, ctx)
return
try:
for f in ctx.lattice.files:
_write_file_content(attachment_path, f.location, file_content[f.id])
except Exception as e:
LOGGER.exception("lattice file write error: %s", e)
ctx.errors._global = "Lattice file write error"
#Rollback?
send_status(500, ctx)
return
send_status(201, ctx)
return