我们从Python开源项目中,提取了以下6个代码示例,用于说明如何使用google.appengine.ext.db.model_from_protobuf()。
def _fetch_latest_from_memcache(app_version): """Get the latest configuration data for this app-version from memcache. Args: app_version: the major version you want configuration data for. Returns: A Config class instance for most recently set options or None if none could be found in memcache. """ proto_string = memcache.get(app_version, namespace=NAMESPACE) if proto_string: logging.debug('Loaded most recent conf data from memcache.') return db.model_from_protobuf(proto_string) logging.debug('Tried to load conf data from memcache, but found nothing.') return None
def get_document(request): """Decodes document from prospective_search result POST request. Args: request: received POST request Returns: document: original datastore.Entity or db.Model document from match call. Raises: DocumentTypeError: """ from google.appengine.ext import db doc_class = request.get('python_document_class') if not doc_class: return None entity = entity_pb.EntityProto() entity.ParseFromString(base64.urlsafe_b64decode( request.get('document').encode('utf-8'))) doc_class = int(doc_class) if doc_class is _doc_class.ENTITY: return datastore.Entity('temp-kind').FromPb(entity) elif doc_class is _doc_class.MODEL: return db.model_from_protobuf(entity) else: raise DocumentTypeError()