本文整理匯總了Python中tornado.util.ObjectDict.model方法的典型用法代碼示例。如果您正苦於以下問題:Python ObjectDict.model方法的具體用法?Python ObjectDict.model怎麽用?Python ObjectDict.model使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tornado.util.ObjectDict
的用法示例。
在下文中一共展示了ObjectDict.model方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _create_upload_context
# 需要導入模塊: from tornado.util import ObjectDict [as 別名]
# 或者: from tornado.util.ObjectDict import model [as 別名]
def _create_upload_context(self):
data = self.application.data
ctx = ObjectDict()
ctx.upload_active = True
ctx.particle_types, ctx.model_types, ctx.lattices = yield [
data.find_particle_types(), data.find_model_types(), data.find_lattices()
]
ctx.model = ObjectDict(model_type=self.model_type)
ctx.errors = ObjectDict()
raise Return(ctx)
示例2: post
# 需要導入模塊: from tornado.util import ObjectDict [as 別名]
# 或者: from tornado.util.ObjectDict import model [as 別名]
def post(self):
data = self.application.data
model_ids = self.get_arguments("model")
if len(model_ids) < 2:
self.send_error(400, message="Must select two models for comparison")
return
model1, model2 = yield [
data.find_model_by_id(model_ids[0]),
data.find_model_by_id(model_ids[1])
]
if not model1:
self.send_error(400, message="Model (1) not found: " + model_ids[0])
return
if not model2:
self.send_error(400, message="Model (2) not found: " + model_ids[1])
return
lattice1, lattice2, model_elements1, model_elements2 = yield [
data.find_lattice_by_id(model1.lattice_id),
data.find_lattice_by_id(model2.lattice_id),
data.find_model_elements_by_model_id(model1._id),
data.find_model_elements_by_model_id(model2._id)
]
ctx = ObjectDict()
ctx.model = (model1, model2)
ctx.lattice = (lattice1, lattice2)
n1 = len(model_elements1)
n2 = len(model_elements2)
ctx.model_elements = []
for idx in range(max(n1, n2)):
if idx < n1 and idx < n2:
ctx.model_elements.append((model_elements1[idx], model_elements2[idx]))
elif idx < n1:
ctx.model_elements.append((model_elements1[idx], None))
elif idx < n2:
ctx.model_elements.append((None, model_elements2[idx]))
self.render("latticemodel/model_compare.html", **ctx)