當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。