.render() works fine on Rows objects with compact=True, and it also works
fine on the results of .sort(), .exclude(), &, and | operations. The only
problem is with the results of .find() operations when the original Rows
object has compact=True. The problem is that the .find() method modifies
the Row objects in self.records when compact=True, which it probably should
not due.
Aside from this issue, perhaps the various Rows methods should preserve the
"compact" attribute -- not sure why they don't.
Forwarding to the developers list for discussion.
Anthony
On Tuesday, January 7, 2014 3:10:00 AM UTC-5, Joe Barnhart wrote:
>
> 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
> or other.compact))
>
>
> In the case above, the flag compact will be set True if either of the
> participating Rows object is also "compact". My logic is, if you've lost
> the "table" values on either Rows object, you may as well lose them on the
> combined set.
>
> 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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.