Python google.appengine.ext.db 模块,model_from_protobuf() 实例源码

我们从Python开源项目中,提取了以下6个代码示例,用于说明如何使用google.appengine.ext.db.model_from_protobuf()

项目:Deploy_XXNET_Server    作者:jzp820927    | 项目源码 | 文件源码
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
项目:Intranet-Penetration    作者:yuxiaokui    | 项目源码 | 文件源码
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()
项目:MKFQ    作者:maojingios    | 项目源码 | 文件源码
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()
项目:xxNet    作者:drzorm    | 项目源码 | 文件源码
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()
项目:Deploy_XXNET_Server    作者:jzp820927    | 项目源码 | 文件源码
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()
项目:Docker-XX-Net    作者:kuanghy    | 项目源码 | 文件源码
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()