本文整理汇总了Python中google.appengine.api.datastore_types.Key._FromPb方法的典型用法代码示例。如果您正苦于以下问题:Python Key._FromPb方法的具体用法?Python Key._FromPb怎么用?Python Key._FromPb使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类google.appengine.api.datastore_types.Key
的用法示例。
在下文中一共展示了Key._FromPb方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_result
# 需要导入模块: from google.appengine.api.datastore_types import Key [as 别名]
# 或者: from google.appengine.api.datastore_types.Key import _FromPb [as 别名]
def get_result(self):
if self.cache_result is not None:
return self.cache_result
if len(self.exception) >= 1:
raise self.exception[0]
resp = self.rpc.response
keys = resp.key_list()
entities = self._entities
multiple = self.multiple
tx = self.tx
num_keys = len(keys)
num_entities = len(entities)
if num_keys != num_entities:
raise datastore_errors.InternalError(
'Put accepted %d entities but returned %d keys.' %
(num_entities, num_keys))
for entity, key in zip(entities, keys):
entity._Entity__key._Key__reference.CopyFrom(key)
if tx:
tx.entity_group = entities[0].entity_group()
if multiple:
return [Key._FromPb(k) for k in keys]
else:
return Key._FromPb(resp.key(0))
示例2: finish
# 需要导入模块: from google.appengine.api.datastore_types import Key [as 别名]
# 或者: from google.appengine.api.datastore_types.Key import _FromPb [as 别名]
def finish(self):
try:
if self._keys_only:
results = [Key._FromPb(e.key()) for e in self._buffer[:self._limit]]
else:
results = [Entity._FromPb(e) for e in self._buffer[:self._limit]]
if self._model_class is not None:
from_entity = self._model_class.from_entity
results = [from_entity(e) for e in results]
else:
results = [class_for_kind(e.kind()).from_entity(e) for e in results]
finally:
del self._buffer[:]
if self.on_complete:
results = self.on_complete(results)
self.set_result(self._value, results)
示例3: process_query_result
# 需要导入模块: from google.appengine.api.datastore_types import Key [as 别名]
# 或者: from google.appengine.api.datastore_types.Key import _FromPb [as 别名]
def process_query_result(result):
if result.keys_only():
return [Key._FromPb(e.key()) for e in result.result_list()]
else:
return [Entity._FromPb(e) for e in result.result_list()]