diff --git a/VERSION b/VERSION index bfe480c7..b9c7b62f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.0.3 (2012-08-30 17:36:15) stable +Version 2.0.3 (2012-08-30 20:07:31) stable diff --git a/gluon/dal.py b/gluon/dal.py index 0ede6db1..b053af81 100644 --- a/gluon/dal.py +++ b/gluon/dal.py @@ -8946,18 +8946,24 @@ class Rows(object): return None return self[-1] - def find(self,f): + def find(self,f,limitby=None): """ returns a new Rows object, a subset of the original object, filtered by the function f """ - if not self.records: + if not self: return Rows(self.db, [], self.colnames) records = [] - for i in range(0,len(self)): - row = self[i] + if limitby: + a,b = limitby + else: + a,b = 0,len(self) + k = 0 + for row in self: if f(row): - records.append(self.records[i]) + if a<=k: records.append(row) + k += 1 + if k==b: break return Rows(self.db, records, self.colnames) def exclude(self, f):