[Zope-CMF] Sorting Search Results by Path...

Jeff Ross thejeffross@hotmail.com
Thu, 12 Sep 2002 16:23:35 -0700


Ok. I tried this and I got an error. I cut out most of the stack trace.

Here's the bit of code it's failing on in UnIndex.py:

    def keyForDocument(self, id):
        return self._unindex[id]

Jeff
___________________________________________________________

Site Error
An error was encountered while publishing this resource.

Error Type: TALESError
Error Value: exceptions.KeyError on -1816271904 in '', at line 10, column 1

  File C:\Program Files\Zope\lib\python\Products\CMFCore\CatalogTool.py,
line 214, in searchResults
    (Object: portal_catalog)
  File C:\Program Files\Zope\lib\python\Products\ZCatalog\ZCatalog.py, line
579, in searchResults
    (Object: portal_catalog)
  File C:\Program Files\Zope\lib\python\Products\ZCatalog\Catalog.py, line
576, in searchResults
  File C:\Program Files\Zope\lib\python\Products\ZCatalog\Catalog.py, line
534, in _indexedSearch
  File C:\Program
Files\Zope\lib\python\Products\PluginIndexes\common\UnIndex.py, line 404, in
keyForDocument
    (Object: sortPath)
TALESError: (see above)



----- Original Message -----
From: "Tres Seaver" <tseaver@zope.com>
To: "Jeff Ross" <thejeffross@hotmail.com>
Cc: "zope-cmf" <zope-cmf@zope.org>
Sent: Wednesday, September 11, 2002 6:33 AM
Subject: Re: [Zope-CMF] Sorting Search Results by Path...


> On Tue, 2002-09-10 at 20:59, Jeff Ross wrote:
> > I'm creating a "My Documents" page in my portal in which each user can
see
> > the documents they created. I'm basing my page on search.pt. It was easy
> > enough to search by the Creator field, but I can't figure out how to
sort
> > the results by path. I've tried adding "sort_on=path" to the query
string,
> > but this just gives me:
> >
> > Error Value: Products.ZCatalog.Catalog.CatalogError on The index chosen
for
> > sort_on is not capable of being used as a sort index. in '', at line 10,
> > column 1
>
> You will need to extend your catalog:
>
>   1. Create a new PythonScript in your 'custom' skins directory,
>      'sortPath', with the body, 'return context.getPhysicalPath()'.
>
>   2. Add a new FieldIndex, 'sortPath', to your catalog, and re-index it.
>
>   3. Use 'sort_on="sortPath"' in your query.
>
> Tres.
> --
> ===============================================================
> Tres Seaver                                tseaver@zope.com
> Zope Corporation      "Zope Dealers"       http://www.zope.com
>