# HG changeset patch # User Sylvain Thénault # Date 1256111275 -7200 # Node ID 034aa14b740a51055e357a23f64944e24feacfb9 # Parent bc61e5211477e79e9b7041cd505f605322672693 drop _prepare_copy method from rset in favor of a more generic copy method diff -r bc61e5211477 -r 034aa14b740a devtools/testlib.py --- a/devtools/testlib.py Wed Oct 21 08:59:14 2009 +0200 +++ b/devtools/testlib.py Wed Oct 21 09:47:55 2009 +0200 @@ -325,7 +325,7 @@ if k.endswith('visible') and not v['default']: propdefs[k]['default'] = True for view in self.list_views_for(rset): - backup_rset = rset._prepare_copy(rset.rows, rset.description) + backup_rset = rset.copy(rset.rows, rset.description) yield InnerTest(self._testname(rset, view.id, 'view'), self.view, view.id, rset, rset.req.reset_headers(), 'main-template') diff -r bc61e5211477 -r 034aa14b740a rset.py --- a/rset.py Wed Oct 21 08:59:14 2009 +0200 +++ b/rset.py Wed Oct 21 09:47:55 2009 +0200 @@ -117,11 +117,10 @@ self.description +rset.description) return self.req.decorate_rset(rset) - def copy(self): - rset = ResultSet(self.rows[:], self.rql, self.args, self.description[:]) - return self.req.decorate_rset(rset) - - def _prepare_copy(self, rows, descr): + def copy(self, rows=None, descr=None): + if rows is None: + rows = self.rows[:] + descr = self.description[:] rset = ResultSet(rows, self.rql, self.args, descr) return self.req.decorate_rset(rset) @@ -140,7 +139,7 @@ :rtype: `ResultSet` """ rows, descr = [], [] - rset = self._prepare_copy(rows, descr) + rset = self.copy(rows, descr) for row, desc in zip(self.rows, self.description): nrow, ndesc = transformcb(row, desc) if ndesc: # transformcb returns None for ndesc to skip that row @@ -163,7 +162,7 @@ :rtype: `ResultSet` """ rows, descr = [], [] - rset = self._prepare_copy(rows, descr) + rset = self.copy(rows, descr) for i in xrange(len(self)): if not filtercb(self.get_entity(i, col)): continue @@ -190,7 +189,7 @@ :rtype: `ResultSet` """ rows, descr = [], [] - rset = self._prepare_copy(rows, descr) + rset = self.copy(rows, descr) if col >= 0: entities = sorted(enumerate(self.entities(col)), key=lambda (i, e): keyfunc(e), reverse=reverse) @@ -237,7 +236,7 @@ if key not in mapping: rows, descr = [], [] - rset = self._prepare_copy(rows, descr) + rset = self.copy(rows, descr) mapping[key] = rset result.append(rset) else: @@ -289,7 +288,7 @@ else: self.req.drop_entity_cache(entity.eid) else: - rset = self._prepare_copy(rows, descr) + rset = self.copy(rows, descr) if not offset: # can copy built entity caches copy_cache(rset, 'get_entity', self)