本文整理汇总了Python中tornado.util.ObjectDict.properties方法的典型用法代码示例。如果您正苦于以下问题:Python ObjectDict.properties方法的具体用法?Python ObjectDict.properties怎么用?Python ObjectDict.properties使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tornado.util.ObjectDict
的用法示例。
在下文中一共展示了ObjectDict.properties方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _form_upload_post
# 需要导入模块: from tornado.util import ObjectDict [as 别名]
# 或者: from tornado.util.ObjectDict import properties [as 别名]
def _form_upload_post(self, send_status):
"""Process the POST request and create new Model resource from form data.
:param send_status: callback method to signal completion
"""
import time
data = self.application.data
ctx = yield self._create_upload_context()
now = time.clock()
content_type = self.handler.request.headers["Content-Type"]
if not content_type.startswith("multipart/form-data;"):
send_status(415, ctx)
return
ctx.model["lattice_id"] = self.handler.get_argument("lattice_id", "")
if len(ctx.model["lattice_id"]) == 0:
ctx.errors["lattice_id"] = "Lattice is required"
else:
ctx.model["lattice_id"] = ObjectId(ctx.model["lattice_id"])
for lattice in ctx.lattices:
if lattice._id == ctx.model["lattice_id"]:
break
else:
ctx.errors["lattice_id"] = "Lattice not found"
ctx.model.name = self.handler.get_argument("name", "")
if len(ctx.model.name) == 0:
ctx.errors.name = "Name is required"
ctx.model.description = self.handler.get_argument("description", "")
ctx.model.status_type = self.handler.get_argument("status_type", "")
ctx.model.created_by = self.handler.current_user
ctx.model.created_date = datetime.now()
ctx.model._id = ObjectId()
ctx.model.files = []
file_content = {}
request_files = self.handler.request.files
modelfiles = {
"fort18":"model_fort18",
"fort24":"model_fort24",
"fort25":"model_fort25",
"fort26":"model_fort26"
}
modelargs = {}
for key, name in modelfiles.iteritems():
if name in request_files and len(request_files[name]) > 0:
modelargs[key] = StringIO(request_files[name][0].body)
# find a unique file ID
while True:
file_id=_create_file_id()
if file_id not in file_content:
break
ctx.model.files.append(ObjectDict(
id=file_id,
name="ModelData",
size=len(request_files[name][0].body),
filename=request_files[name][0].filename,
location=_create_file_location(request_files[name][0])
))
file_content[file_id] = request_files[name][0].body
else:
ctx.errors[name] = "Model data file is required"
if ctx.errors:
send_status(400, ctx)
return
for p in lattice.properties:
if p.name == "OutputMode":
outputMode = p.value
break
else:
ctx.errors.lattice_id = "Lattice missing 'OutputMode' property"
send_status(400, ctx)
return
if outputMode not in [1, 2, 3, 4, 5, 6]:
ctx.errors.lattice_id = "Lattice 'OutputMode' unsupported"
send_status(400, ctx)
return
try:
model = build_result(**modelargs)
except Exception as e:
LOGGER.warning("Error building model: %s", e)
ctx.errors._global = "Model invalid format"
send_status(400, ctx)
return
#.........这里部分代码省略.........