1
# Copyright (c) 2006,2007,2008 Mitch Garnaat http://garnaat.org/
3
# Permission is hereby granted, free of charge, to any person obtaining a
4
# copy of this software and associated documentation files (the
5
# "Software"), to deal in the Software without restriction, including
6
# without limitation the rights to use, copy, modify, merge, publish, dis-
7
# tribute, sublicense, and/or sell copies of the Software, and to permit
8
# persons to whom the Software is furnished to do so, subject to the fol-
11
# The above copyright notice and this permission notice shall be included
12
# in all copies or substantial portions of the Software.
14
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
16
# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
17
# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24
def __init__(self, model_class, limit=None, next_token=None, manager=None):
25
self.model_class = model_class
28
self.manager = manager
30
self.manager = self.model_class._manager
34
self.next_token = next_token
37
return iter(self.manager.query(self))
40
if self.__local_iter__ == None:
41
self.__local_iter__ = self.__iter__()
42
return self.__local_iter__.next()
44
def filter(self, property_operator, value):
45
self.filters.append((property_operator, value))
48
def fetch(self, limit, offset=0):
49
raise NotImplementedError, "fetch mode is not currently supported"
52
return self.manager.count(self.model_class, self.filters)
55
return self.manager._build_filter_part(self.model_class, self.filters, self.sort_by)
61
def to_xml(self, doc=None):
63
xmlmanager = self.model_class.get_xmlmanager()
64
doc = xmlmanager.new_doc()
69
def get_next_token(self):
71
return self.rs.next_token
73
return self._next_token
76
def set_next_token(self, token):
77
self._next_token = token
79
next_token = property(get_next_token, set_next_token)