当前位置: 首页>>代码示例>>Python>>正文


Python ObjectDict._id方法代码示例

本文整理汇总了Python中tornado.util.ObjectDict._id方法的典型用法代码示例。如果您正苦于以下问题:Python ObjectDict._id方法的具体用法?Python ObjectDict._id怎么用?Python ObjectDict._id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tornado.util.ObjectDict的用法示例。


在下文中一共展示了ObjectDict._id方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _find_user

# 需要导入模块: from tornado.util import ObjectDict [as 别名]
# 或者: from tornado.util.ObjectDict import _id [as 别名]
 def _find_user(self, account):
     rs = self.db.query("SELECT * FROM users WHERE account=%s", account)
     if not rs:
         return None
     r = rs[0]
     d = copy.deepcopy(r)
     d = ObjectDict(d)
     d._id = d.id
     del d['id']
     del d['auth_time']
     del d['ins_time']
     d.user_no = str(d.user_no)
     d.token = self._gen_token(d._id, d.user_no)
     if d.ext_data:
         d.ext_data = json.loads(d.ext_data)
     d['class'] = 'user'  # TODO class是python关键字,不建议用对象属性的方法赋值
     return d
开发者ID:demotools,项目名称:dizigui-server,代码行数:19,代码来源:auth.py

示例2: _form_upload_post

# 需要导入模块: from tornado.util import ObjectDict [as 别名]
# 或者: from tornado.util.ObjectDict import _id [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

#.........这里部分代码省略.........
开发者ID:frib-high-level-controls,项目名称:phyhlc,代码行数:103,代码来源:impact.py


注:本文中的tornado.util.ObjectDict._id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。