cannot iterate catalog brains when sort is defined

Bug #143504 reported by kedai
2
Affects Status Importance Assigned to Milestone
Zope 2
Invalid
Low
Unassigned

Bug Description

attached is a minimal setup (zexp)

import to zope instance, try view test. all shoud be ok

try testsort .. we'll get
Error Type: TypeError
 Error Value: mybrains.__cmp__(x,y) requires y to be a 'mybrains', not a 'ImplicitAcquirerWrapper'

the only difference is the sort='something' in dtml-in

tq

Tags: bug zope
Revision history for this message
kedai (kedai) wrote :
Revision history for this message
Simon Michael (simon) wrote :

In case it helps: I get this with Zope 2.8.1 at DT_In.py line 783 when doing < dtml-in results sort=lastEditTime ... >. It worked with Zope 2.7. The list s at that point looks like:

 (Pdb) for i in U: print i
 (DateTime('2004/10/29 13:09:28 GMT-7'), <Products.ZCatalog.Catalog.mybrains object at 0x423acbe4>)
 (DateTime('2004/11/18 12:36:56 US/Pacific'), <Products.ZCatalog.Catalog.mybrains object at 0x423acb44>)
 ...

I get the same error when comparing two of these brains, eg:

 (Pdb) b1 < b2
*** TypeError: mybrains.__cmp__(x,y) requires y to be a 'mybrains', not a 'ImplicitAcquirerWrapper'

Revision history for this message
Simon Michael (simon) wrote :

Adding this to Products.ZCatalog.CatalogBrains.AbstractCatalogBrain fixes the crash::

    def __cmp__(self, other): return 0

Brains don't need to be sortable in the situation below. I don't know if that's always true though.

Revision history for this message
Simon Michael (simon) wrote :

This problem still exists in 2.9.0, and can be worked around by the same patch.

I reproduce it with <dtml-in pages sort=creation_time></dtml-in> in a zwiki page. pages returns a list of catalog brains, the creation_time attribute is a string.

Revision history for this message
Florent Guillaume (efge) wrote :
Revision history for this message
JJózsef (jaroli) wrote :

Workaround: patch your zope by adding this to SOFTWARE_HOME/lib/python/Products/ZCatalog/CatalogBrains?.py AbstractCatalogBrain class:

def __cmp__(self, other): return 0

source: http://zwiki.org/1145MybrainsCmpErrorWithRecentChangesSearchOnZope28

Revision history for this message
Tres Seaver (tseaver) wrote :

The other collector issue is now lp:143642

Changed in zope2:
importance: Medium → Low
status: New → Triaged
Revision history for this message
Vladislav Vorobiev (mymir-org) wrote :

Why did not fix it?

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: Triaged → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

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