I've been experimenting with the render method of the Rows class, and I am 
very impressed.  But one drawback I found is that the Rows object must have 
its value set to "compact=False" to work properly with render().  It isn't 
a problem if the Rows object is used directly without any operators, but I 
discovered that many, if not most, Rows methods do not preserve the 
"compact" setting.

For example. if you "sort" the Rows, it leaves compact=True.  Ditto, if you 
use "extract" or "find" on the Rows object.  The "&" and "|" operators also 
set the compact variable to "True".  The upshot is that you can't use any 
of these operators on the Rows object and then use "render" on the 
resulting object.

It is a simple change to add the preservation of the "compact" flag during 
any of these steps, but I'm unsure if this will break existing code.  Other 
than coming up with a completely parallel set of methods, which leave 
compact set the way it came in, I can't think of another approach will be 
provably backwards-compatible.

Here is an example:


    def __and__(self,other):
        if self.colnames!=other.colnames:
            raise Exception('Cannot & incompatible Rows objects')
        records = self.records+other.records
        return Rows(self.db,records,self.colnames)


Becomes:


    def __and__(self,other):
        if self.colnames!=other.colnames:
            raise Exception('Cannot & incompatible Rows objects')
        records = self.records+other.records
        return Rows(self.db,records,self.colnames,compact=(self.compact and 
other.compact))


Going through the other methods we could make a Rows object preserve its 
compact setting while undergoing these transformations.

What do you think?

-- Joe B.


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to