<s> from boto . compat import six <EOL> class Query ( object ) : <EOL> __local_iter__ = None <EOL> def __init__ ( self , model_class , limit = None , next_token = None , manager = None ) : <EOL> self . model_class = model_class <EOL> self . limit = limit <EOL> self . offset = <NUM_LIT:0> <EOL> if manager : <EOL> self . manager = manager <EOL> else : <EOL> self . manager = self . model_class . _manager <EOL> self . filters = [ ] <EOL> self . select = None <EOL> self . sort_by = None <EOL> self . rs = None <EOL> self . next_token = next_token <EOL> def __iter__ ( self ) : <EOL> return iter ( self . manager . query ( self ) ) <EOL> def next ( self ) : <EOL> if self . __local_iter__ is None : <EOL> self . __local_iter__ = self . __iter__ ( ) <EOL> return next ( self . __local_iter__ ) <EOL> def filter ( self , property_operator , value ) : <EOL> self . filters . append ( ( property_operator , value ) ) <EOL> return self <EOL> def fetch ( self , limit , offset = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> self . limit = limit <EOL> self . offset = offset <EOL> return self <EOL> def count ( self , quick = True ) : <EOL> return self . manager . count ( self . model_class , self . filters , quick , self . sort_by , self . select ) <EOL> def get_query ( self ) : <EOL> return self . manager . _build_filter_part ( self . model_class , self . filters , self . sort_by , self . select ) <EOL> def order ( self , key ) : <EOL> self . sort_by = key <EOL> return self <EOL> def to_xml ( self , doc = None ) : <EOL> if not doc : <EOL> xmlmanager = self . model_class . get_xmlmanager ( ) <EOL> doc = xmlmanager . new_doc ( ) <EOL> for obj in self : <EOL> obj . to_xml ( doc ) <EOL> return doc <EOL> def get_next_token ( self ) : <EOL> if self . rs : <EOL> return self . rs . next_token <EOL> if self . _next_token : <EOL> return self . _next_token <EOL> return None <EOL> def set_next_token ( self , token ) : <EOL> self . _next_token = token <EOL> next_token = property ( get_next_token , set_next_token ) </s>
