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


Python TypedObject.serialize方法代码示例

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


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

示例1: apply

# 需要导入模块: from dctmpy.obj.typedobject import TypedObject [as 别名]
# 或者: from dctmpy.obj.typedobject.TypedObject import serialize [as 别名]
    def apply(self, rpc_id, object_id, method, request=None, cls=Collection):
        if rpc_id is None:
            rpc_id = RPC_APPLY

        if not object_id:
            object_id = NULL_ID

        req = request
        if object_id != NULL_ID and req is None:
            req = TypedObject(session=self)
        if isinstance(req, TypedObject):
            req = req.serialize()
        if req and len(req) > MAX_REQUEST_LEN:
            return self.apply_chunks(rpc_id, object_id, method, req, cls)

        response = self.rpc(rpc_id, [self._get_method(method), object_id, req])
        data = response.data

        if rpc_id == RPC_APPLY_FOR_STRING:
            return str(data)
        elif rpc_id == RPC_APPLY_FOR_ID:
            return str(data)
        elif rpc_id == RPC_APPLY_FOR_DOUBLE:
            return data
        elif rpc_id == RPC_APPLY_FOR_BOOL:
            return int(data) == 1
        elif rpc_id == RPC_APPLY_FOR_LONG:
            return data
        elif rpc_id == RPC_APPLY_FOR_TIME:
            return data

        if not cls:
            if rpc_id == RPC_APPLY:
                cls = Collection
            elif rpc_id == RPC_APPLY_FOR_OBJECT:
                cls = TypedObject

        if response.persistent:
            if cls == Collection:
                cls = PersistentCollection
            elif cls == TypedObject:
                cls = PersistentProxy

        if is_empty(data):
            return None

        result = cls(session=self, buffer=data)
        if response.collection is not None and isinstance(result, Collection):
            result.collection = response.collection
            result.persistent = response.persistent
            result.record_count = response.record_count
            result.may_be_more = response.may_be_more
            if isinstance(request, TypedObject) and 'BATCH_HINT' in request:
                result.batch_size = request['BATCH_HINT']
            else:
                result.batch_size = DEFAULT_BATCH_SIZE

        if isinstance(result, Collection):
            self.collections[result.collection] = result

        return result
开发者ID:andreybpanfilov,项目名称:dctmpy,代码行数:63,代码来源:docbaseclient.py


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