def CheckReference(request_trusted, request_app_id, key, require_id_or_name=True):
 assert isinstance(key, entity_pb.Reference)
 CheckAppId(request_trusted, request_app_id, key.app())
 Check((key.path().element_size() > 0), "key's path cannot be empty")
 if require_id_or_name:
  last_element = key.path().element_list()[(-1)]
  has_id_or_name = ((last_element.has_id() and (last_element.id() != 0)) or (last_element.has_name() and (last_element.name() != '')))
  if (not has_id_or_name):
   raise datastore_errors.BadRequestError('missing key id/name')
 for elem in key.path().element_list():
  Check(((not elem.has_id()) or (not elem.has_name())), ('each key path element should have id or name but not both: %r' % key))

def CheckReference ( request_trusted , request_app_id , key , require_id_or_name = True ) : assert isinstance ( key , entity_pb . Reference ) CheckAppId ( request_trusted , request_app_id , key . app ( ) ) Check ( ( key . path ( ) . element_size ( ) > 0 ) , "key's path cannot be empty" ) if require_id_or_name : last_element = key . path ( ) . element_list ( ) [ ( - 1 ) ] has_id_or_name = ( ( last_element . has_id ( ) and ( last_element . id ( ) != 0 ) ) or ( last_element . has_name ( ) and ( last_element . name ( ) != '' ) ) ) if ( not has_id_or_name ) : raise datastore_errors . BadRequestError ( 'missing key id/name' ) for elem in key . path ( ) . element_list ( ) : Check ( ( ( not elem . has_id ( ) ) or ( not elem . has_name ( ) ) ) , ( 'each key path element should have id or name but not both: %r' % key ) )
check this key .