本文整理汇总了Python中tornado.util.ObjectDict.lattice_elements方法的典型用法代码示例。如果您正苦于以下问题:Python ObjectDict.lattice_elements方法的具体用法?Python ObjectDict.lattice_elements怎么用?Python ObjectDict.lattice_elements使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tornado.util.ObjectDict
的用法示例。
在下文中一共展示了ObjectDict.lattice_elements方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from tornado.util import ObjectDict [as 别名]
# 或者: from tornado.util.ObjectDict import lattice_elements [as 别名]
def post(self):
data = self.application.data
lattice_ids = self.get_arguments("lattice")
if len(lattice_ids) < 2:
self.send_error(400, message="Must select two lattice for comparison")
return
lattice1 = yield data.find_lattice_by_id(lattice_ids[0])
if not lattice1:
self.send_error(400, message="Lattice (1) not found: " + lattice_ids[0])
return
lattice_elements1 = yield data.find_lattice_elements_by_lattice_id(lattice_ids[0])
lattice2 = yield data.find_lattice_by_id(lattice_ids[1])
if not lattice2:
self.send_error(400, message="Lattice (2) not found: " + lattice_ids[1])
return
lattice_elements2 = yield data.find_lattice_elements_by_lattice_id(lattice_ids[1])
ctx = ObjectDict()
ctx.lattice = (lattice1, lattice2)
n1 = len(lattice_elements1)
n2 = len(lattice_elements2)
ctx.lattice_elements = []
for idx in range(max(n1, n2)):
if idx < n1 and idx < n2:
ctx.lattice_elements.append((lattice_elements1[idx], lattice_elements2[idx]))
elif idx < n1:
ctx.lattice_elements.append((lattice_elements1[idx], None))
elif idx < n2:
ctx.lattice_elements.append((None, lattice_elements2[idx]))
ctx.particle_types = yield data.find_particle_types()
self.render("latticemodel/lattice_compare.html", **ctx)
示例2: get
# 需要导入模块: from tornado.util import ObjectDict [as 别名]
# 或者: from tornado.util.ObjectDict import lattice_elements [as 别名]
def get(self, model_id):
ctx = ObjectDict()
data = self.application.data
ctx.model, ctx.model_elements = yield [
data.find_model_by_id(model_id),
data.find_model_elements_by_model_id(model_id)
]
#data.find_lattice_elements_by_lattice_id(lattice_id)
if not ctx.model:
self.render_error(404)
return
ctx.lattice, lattice_elements = yield [
data.find_lattice_by_id(ctx.model.lattice_id),
data.find_lattice_elements_by_lattice_id(ctx.model.lattice_id)
]
ctx.lattice_elements = {}
for lattice_element in lattice_elements:
ctx.lattice_elements[lattice_element._id] = lattice_element
self.render("latticemodel/model_details.html", ctx)