本文整理匯總了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