ZCatalog : sortResults does not work anymore

Bug #1236790 reported by Thomas Desvenain
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Zope 2
Invalid
Undecided
Unassigned

Bug Description

_limit_sequence is uneffective when it takes as a parameter a sequence of (key, items, getitem) instead of a sequence of items.

the consequence is that sorting + limiting results does not work anymore

i discovered that because it breaks test_queryCatalogAddCriteria in Products.ATContentTypes

Revision history for this message
Thomas Desvenain (thomas-desvenain) wrote :

Failure in test test_queryCatalogAddCriteria (Products.ATContentTypes.tests.test_attopic.TestSiteATTopic)
Traceback (most recent call last):
  File "/usr/lib/python2.7/unittest/case.py", line 332, in run
    testMethod()
  File "/home/thomas/buildouts/buildout.coredev/src/Products.ATContentTypes/Products/ATContentTypes/tests/test_attopic.py", line 402, in test_queryCatalogAddCriteria
    self.assertEqual(len(topic.queryCatalog(sort_on='Date', sort_limit=5)), 5)
  File "/usr/lib/python2.7/unittest/case.py", line 516, in assertEqual
    assertion_func(first, second, msg=msg)
  File "/usr/lib/python2.7/unittest/case.py", line 509, in _baseAssertEqual
    raise self.failureException(msg)
AssertionError: 1 != 5

len(topic.queryCatalog(sort_on='Date', sort_limit=5) -> 1
len([r for r in topic.queryCatalog(sort_on='Date', sort_limit=5)]) -> 23

Revision history for this message
Thomas Desvenain (thomas-desvenain) wrote :

489 def _limit_sequence(self, sequence, slen, b_start=0, b_size=None,
490 switched_reverse=False):
491 if b_size == 5:import pdb; pdb.set_trace()
492 -> if b_size is not None:
493 sequence = sequence[b_start:b_start + b_size]
494 if slen:
495 slen = len(sequence)
496 if switched_reverse:
497 sequence.reverse()
(Pdb) args
self = <Products.ZCatalog.Catalog.Catalog object at 0x83b7758>
sequence = [(1078782419, [-664698048, -664698046, -664698044, 1157005748, 1157005750, 1157005751, 1157005752, 1157005753, 1157005754, 1157005755, 1157005756, 1157005757, 1157005758, 1157005759, 1157005760, 1157005761, 1157005762, 1157005763, 1157005764, 1157005765, 1157005766, 1157005767, 1157005768], <bound method Catalog.__getitem__ of <Products.ZCatalog.Catalog.Catalog object at 0x83b7758>>)]
slen = 23
b_start = 0
b_size = 5
switched_reverse = False

...

493: sequence[b_start:b_start + b_size] -> this is not accurate

Revision history for this message
Hanno Schlichting (hannosch) wrote :

I think I've fixed this in https://github.com/zopefoundation/Products.ZCatalog/commit/1b23ee66052a5ea9bc9c57a550917b4279d5fa4d. I wasn't related to multi-sorting, but removal of a `limit is None` protection for one of the search algorithms. This was a master only optimization.

Changed in zope2:
status: New → Fix Committed
summary: - ZCatalog : sortResults does not work anymore [critical]
+ ZCatalog : sortResults does not work anymore
Revision history for this message
Colin Watson (cjwatson) wrote :

The zope2 project on Launchpad has been archived at the request of the Zope developers (see https://answers.launchpad.net/launchpad/+question/683589 and https://answers.launchpad.net/launchpad/+question/685285). If this bug is still relevant, please refile it at https://github.com/zopefoundation/zope2.

Changed in zope2:
status: Fix Committed → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.