thirdparty/google_appengine/google/appengine/api/datastore_admin.py
changeset 2864 2e0b0af889be
parent 149 f2e327a7c5de
equal deleted inserted replaced
2862:27971a13089f 2864:2e0b0af889be
    37     'desc':       entity_pb.Index_Property.DESCENDING,
    37     'desc':       entity_pb.Index_Property.DESCENDING,
    38     'descending': entity_pb.Index_Property.DESCENDING,
    38     'descending': entity_pb.Index_Property.DESCENDING,
    39     }
    39     }
    40 
    40 
    41 
    41 
    42 def GetSchema(_app=None):
    42 def GetSchema(_app=None, properties=True, start_kind=None, end_kind=None):
    43   """Infers an app's schema from the entities in the datastore.
    43   """Infers an app's schema from the entities in the datastore.
    44 
    44 
    45   Note that the PropertyValue PBs in the returned EntityProtos are empty
    45   Note that the PropertyValue PBs in the returned EntityProtos are empty
    46   placeholders, so they may cause problems if you try to convert them to
    46   placeholders, so they may cause problems if you try to convert them to
    47   python values with e.g. datastore_types. In particular, user values will
    47   python values with e.g. datastore_types. In particular, user values will
    48   throw UserNotFoundError because their email and auth domain fields will be
    48   throw UserNotFoundError because their email and auth domain fields will be
    49   empty.
    49   empty.
    50 
    50 
       
    51   Args:
       
    52     properties: boolean, whether to include property names and types
       
    53     start_kind, end_kind: optional range endpoints for the kinds to return,
       
    54       compared lexicographically
       
    55 
    51   Returns:
    56   Returns:
    52     list of entity_pb.EntityProto, with kind and property names and types
    57     list of entity_pb.EntityProto, with kind and property names and types
    53   """
    58   """
    54   req = api_base_pb.StringProto()
    59   req = datastore_pb.GetSchemaRequest()
    55   req.set_value(datastore_types.ResolveAppId(_app))
    60   req.set_app(datastore_types.ResolveAppId(_app))
       
    61   req.set_properties(properties)
       
    62   if start_kind is not None:
       
    63     req.set_start_kind(start_kind)
       
    64   if end_kind is not None:
       
    65     req.set_end_kind(end_kind)
    56   resp = datastore_pb.Schema()
    66   resp = datastore_pb.Schema()
    57 
    67 
    58   _Call('GetSchema', req, resp)
    68   _Call('GetSchema', req, resp)
    59   return resp.kind_list()
    69   return resp.kind_list()
    60 
    70