#NEWLINE# def ParsePropertyQuery( query , filters , orders ) : #NEWLINE# #INDENT# 'Parse __property__  queries.\n\n  Raises exceptions for illegal queries.\n  Args:\n    query: A Query PB.\n    filters: the normalized filters from query.\n    orders: the normalized orders from query.\n  Returns:\n     The kind range (a ValueRange over (kind, property) pairs) requested\n     in the query.\n  ' #NEWLINE# if query . has_transaction ( ) : #NEWLINE# #INDENT# raise BadRequestError ( 'transactional queries on __property__ not allowed' ) #NEWLINE# #UNINDENT# key_range = ParseKeyFilteredQuery ( filters , orders ) #NEWLINE# key_range . Remap ( ( lambda x : _PropertyKeyToString ( x , '' ) ) ) #NEWLINE# if query . has_ancestor ( ) : #NEWLINE# #INDENT# ancestor = datastore_types . Key . _FromPb ( query . ancestor ( ) ) #NEWLINE# ( ancestor_kind , ancestor_property ) = _PropertyKeyToString ( ancestor , None ) #NEWLINE# if ( ancestor_property is not None ) : #NEWLINE# #INDENT# key_range . Update ( datastore_pb . Query_Filter . EQUAL , ( ancestor_kind , ancestor_property ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# key_range . Update ( datastore_pb . Query_Filter . GREATER_THAN_OR_EQUAL , ( ancestor_kind , '' ) ) #NEWLINE# key_range . Update ( datastore_pb . Query_Filter . LESS_THAN_OR_EQUAL , ( ( ancestor_kind + '\x00' ) , '' ) ) #NEWLINE# #UNINDENT# query . clear_ancestor ( ) #NEWLINE# #UNINDENT# return key_range