I'm getting a strange problem with ZCatalog, using python 2.1, Zope from CVS. I get all the results I expect with this: <ul> <dtml-in "Catalog(process_step=['start','mailed'])"> <li> &dtml-subject_name; -- &dtml-relationship_name; -> &dtml-rater_name; </dtml-in> </ul> But, I only get one subject_name's worth of results with this: <ul> <dtml-in "Catalog(process_step=['start','mailed'], sort_on='subject_name')"> <li> &dtml-subject_name; -- &dtml-relationship_name; -> &dtml-rater_name; </dtml-in> </ul> This smells like a BTrees bug to me, but I'm not sure. I'm looking into this closely now, but if anyone's seen this before, please speak up! -- Steve Alexander Software Engineer Cat-Box limited
Steve Alexander wrote:
I'm getting a strange problem with ZCatalog, using python 2.1, Zope from CVS.
I get all the results I expect with this:
<ul> <dtml-in "Catalog(process_step=['start','mailed'])">
<li> &dtml-subject_name; -- &dtml-relationship_name; -> &dtml-rater_name;
</dtml-in> </ul>
But, I only get one subject_name's worth of results with this:
<ul> <dtml-in "Catalog(process_step=['start','mailed'], sort_on='subject_name')">
<li> &dtml-subject_name; -- &dtml-relationship_name; -> &dtml-rater_name;
</dtml-in> </ul>
This smells like a BTrees bug to me, but I'm not sure. I'm looking into this closely now, but if anyone's seen this before, please speak up!
More data: This gives partial results: <dtml-in "Catalog(process_step=['start','mailed'], sort_on='subject_name')"> This gives full results: <dtml-in "Catalog(process_step=['start','mailed'], sort_on='subject_name')[:]"> This gives full results: <dtml-in "Catalog(process_step=['start','mailed'], sort_on='subject_name')" sort="subject_name"> -- Steve Alexander Software Engineer Cat-Box limited
Steve Alexander wrote:
This gives partial results:
<dtml-in "Catalog(process_step=['start','mailed'], sort_on='subject_name')">
...because this returns a LazyCat instance, for which len() is broken.
This gives full results:
<dtml-in "Catalog(process_step=['start','mailed'], sort_on='subject_name')[:]">
...because this is a list.
This gives full results:
<dtml-in "Catalog(process_step=['start','mailed'], sort_on='subject_name')" sort="subject_name">
...because this is a LazyMap instance, for which len() works. Patch coming up soon... -- Steve Alexander Software Engineer Cat-Box limited
Steve Alexander wrote:
Patch coming up soon...
Patch against Catalog.py, from CVS: *** lib/python/Products/ZCatalog/Catalog.py.original --- lib/python/Products/ZCatalog/Catalog.py.patched *************** *** 673,679 **** if (type(so) is type('') and lower(so) in ('reverse', 'descending')): r.reverse() ! r=LazyCat(map(lambda i: i[1], r), len(r)) return r --- 673,681 ---- if (type(so) is type('') and lower(so) in ('reverse', 'descending')): r.reverse() ! r=map(lambda i: i[1], r) ! r=LazyCat(r, reduce(lambda x,y: x+len(y), r, 0)) ! return r I'd use a list comprehension instead of a map(lambda...) if I thought it would get past Jim ;-) -- Steve Alexander Software Engineer Cat-Box limited
participants (1)
-
Steve Alexander