From 9d13d297cbf71421949d86692a9c5257d812cf0d Mon Sep 17 00:00:00 2001 From: mdipierro Date: Fri, 24 Jan 2014 20:36:21 -0600 Subject: [PATCH] improved Rows methods propagate parameters, thanks Anthony --- VERSION | 2 +- gluon/dal.py | 27 +++++++++++++++++---------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/VERSION b/VERSION index ea3a3c7a..70f37557 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.8.2-stable+timestamp.2014.01.24.16.21.05 +Version 2.8.2-stable+timestamp.2014.01.24.20.35.09 diff --git a/gluon/dal.py b/gluon/dal.py index 4181e596..bc1cd94a 100644 --- a/gluon/dal.py +++ b/gluon/dal.py @@ -10709,7 +10709,8 @@ class Rows(object): if self.colnames!=other.colnames: raise Exception('Cannot & incompatible Rows objects') records = self.records+other.records - return Rows(self.db,records,self.colnames) + return Rows(self.db,records,self.colnames, + compact=self.compact or other.compact) def __or__(self,other): if self.colnames!=other.colnames: @@ -10717,7 +10718,8 @@ class Rows(object): records = [record for record in other.records if not record in self.records] records = self.records + records - return Rows(self.db,records,self.colnames) + return Rows(self.db,records,self.colnames, + compact=self.compact or other.compact) def __nonzero__(self): if len(self.records): @@ -10770,19 +10772,19 @@ class Rows(object): filtered by the function f """ if not self: - return Rows(self.db, [], self.colnames) + return Rows(self.db, [], self.colnames, compact=self.compact) records = [] if limitby: a,b = limitby else: a,b = 0,len(self) k = 0 - for row in self: + for i, row in enumerate(self): if f(row): - if a<=k: records.append(row) + if a<=k: records.append(self.records[i]) k += 1 if k==b: break - return Rows(self.db, records, self.colnames) + return Rows(self.db, records, self.colnames, compact=self.compact) def exclude(self, f): """ @@ -10790,7 +10792,7 @@ class Rows(object): and returns a new Rows object containing the removed elements """ if not self.records: - return Rows(self.db, [], self.colnames) + return Rows(self.db, [], self.colnames, compact=self.compact) removed = [] i=0 while i