Perhaps I am not understanding correctly, but do you have this same problem with a field index for methods as well as properties? Have you tried this on values other than integers? I have, for example, an item that has a method called firstLetter() that obtains title[0:1] and returns it as a string; sort_on='firstLetter' seems to work just fine (2.3.2), even though the return value has many duplicates among the thousands of objects I am sorting; I have not tried sorting on a property for a field index in this manner, though... On an unrelated note (I figured I might as well ask while I'm at it), does anyone know if there is a way to get sort_on to work for field indexes that store dates? sort_on and sort_order seem to be meaningless when applied to indexes containing dates... I assume that a corrective behavior might be to turn the date into a string or an integer (UNIX time, for example) via an indexed method; I just wonder if there is something easier that anyone knows of? Sean -----Original Message----- From: Chris Withers [mailto:chrisw@nipltd.com] Sent: Saturday, July 21, 2001 1:01 AM To: zope-dev@zope.org Cc: Andreas Jung Subject: [Zope-dev] ZCatalog Bug: scope for the problem
I'm doing something simple:
return catalog.searchResults(sort_on='dateofpublication')
...and getting something horrible:
Error Type: TypeError Error Value: unsubscriptable object
Further scoping out this problem has expanded it: - this bug isn't limited to 2.4.0bx, it's also manifests at least in 2.3.2 and probably in 2.3.1+. ...and narrowed it: - the bug occurs when you sort on an index where more than one indexed item has the same value. For example, if: x=SimpleItem() y=SimpleItem() z=Simpleitem() x.fred=1 y.fred=1 z.fred=2 ...now if you have a FieldIndex called 'fred' and catalog this lot, you'll get the error when you do a search along the lines of: r = Catalog(sort_on='fred') However, if you changed it so y.fred=2 and z.fred=3, you wouldn't get any unexpected behaviour :-S It appears that IITreeSet objects don't like being subscripted. That sounds kindof weird, but then it doesn't look like IITreeSets should be appearing in that context anyhow... Help! Chris _______________________________________________ Zope-Dev maillist - Zope-Dev@zope.org http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )