#NEWLINE# def __iter__( self ) : #NEWLINE# #INDENT# 'Iterate over entities.\n\n    Yields:\n      db model entities or ndb model entities if the model is defined with ndb.\n    ' #NEWLINE# for ns in self . _ns_range : #NEWLINE# #INDENT# self . _query = self . _property_range . make_query ( ns ) #NEWLINE# if isinstance ( self . _query , db . Query ) : #NEWLINE# #INDENT# if self . _cursor : #NEWLINE# #INDENT# self . _query . with_cursor ( self . _cursor ) #NEWLINE# #UNINDENT# for model_instance in self . _query . run ( batch_size = self . _query_spec . batch_size , keys_only = self . _query_spec . keys_only ) : #NEWLINE# #INDENT# ( yield model_instance ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# self . _query = self . _query . iter ( batch_size = self . _query_spec . batch_size , keys_only = self . _query_spec . keys_only , start_cursor = self . _cursor , produce_cursors = True ) #NEWLINE# for model_instance in self . _query : #NEWLINE# #INDENT# ( yield model_instance ) #NEWLINE# #UNINDENT# #UNINDENT# self . _query = None #NEWLINE# self . _cursor = None #NEWLINE# if ( ns != self . _ns_range . namespace_end ) : #NEWLINE# #INDENT# self . _ns_range = self . _ns_range . with_start_after ( ns )