[Zope-CMF] Searching CMF returns all objects

Grégoire Weber gregoire.weber@switzerland.org
Thu, 25 Apr 2002 13:46:20 +0200


Hi,

I've tried Tres external method which has to be corrected before runing it.
The following points have to be changed:

  1. Delete the space in the indexes names ('Field Index' --> 'FieldIndex',
etc.)

  2. CMF installations without hotfixed metadata_tool do not have 'end', 
     'reverse_modified' and 'start' indexes. Delete them in the script.

  3. instead of catalog.manage_catalogReindex() use
catalog.refreshCatalog(clear=1)
     You get some funny 'expected 4 parameters, got 1' exceptions otherwise.

<CODE>
from Products.CMFCore.utils import getToolByName

def update_catalogIndexes(self, REQUEST):
    """
        Drop, re-add, and rebuild catalog Indexes for Zope CMF
        sites migrated Zope 2.3 to 2.4+.
    """
    CMF_CATALOG_INDEXES = (
        ( 'Contributors',                  'FieldIndex'   )
        , ( 'Creator',                     'FieldIndex'   )
        , ( 'Date',                        'FieldIndex'   )
        , ( 'Description',                 'TextIndex'    )
        , ( 'PrincipiaSearchSource',       'TextIndex'    )
        , ( 'SearchableText',              'TextIndex'    )
        , ( 'Subject',                     'KeywordIndex' )
        , ( 'Title',                       'TextIndex'    )
        , ( 'Type',                        'FieldIndex'   )
        , ( 'allowedRolesAndUsers',        'KeywordIndex' )
        , ( 'bobobase_modification_time',  'FieldIndex'   )
        , ( 'created',                     'FieldIndex'   )
        , ( 'effective',                   'FieldIndex'   )
        , ( 'expires',                     'FieldIndex'   )
        , ( 'id',                          'FieldIndex'   )
        , ( 'in_reply_to',                 'FieldIndex'   )
        , ( 'meta_type',                   'FieldIndex'   )
        , ( 'modified',                    'FieldIndex'   )
        , ( 'review_state',                'FieldIndex'   )
        , ( 'title',                       'TextIndex'    )
        )

    catalog = getToolByName( self, 'portal_catalog' )

    for index_name, index_type in CMF_CATALOG_INDEXES:
        catalog.delIndex( index_name )
        catalog.addIndex( index_name, index_type )

    catalog.refreshCatalog(clear=1)

    return 'Catalog Indexes rebuilt.'
</CODE>

There exitst another external method in the Extensions directory of CMFDefault
doing the same thing, but only updating three indexes. The list has to be
comleted.


Remaining Problem
-----------------

  Both corrected/completed external methods generate the following error
(site with 
  german content containing 'Umlaute') (Zope 2.5.0):

Traceback:

TypeError
Splitter() got an unexpected keyword argument 'encoding'

Traceback (innermost last):
  File D:\prog\zope_test\lib\python\ZPublisher\Publish.py, line 150, in
publish_module
  File D:\prog\zope_test\lib\python\ZPublisher\Publish.py, line 114, in
publish
  File D:\prog\zope_test\lib\python\Zope\__init__.py, line 158, in
zpublisher_exception_hook
    (Object: up)
  File D:\prog\zope_test\lib\python\ZPublisher\Publish.py, line 98, in publish
  File D:\prog\zope_test\lib\python\ZPublisher\mapply.py, line 88, in mapply
    (Object: update_catalogIndexes)
  File D:\prog\zope_test\lib\python\ZPublisher\Publish.py, line 39, in
call_object
    (Object: update_catalogIndexes)
  File
D:\prog\zope_test\lib\python\Products\ExternalMethod\ExternalMethod.py,
line 202, in __call__
    (Object: update_catalogIndexes)
    (Info: ((<CMFSite instance at 0170B910>,
<h3>form</h3><table></table><h3>cookies</h3><table><tr valign="top"
align="left"><th>tree-s</th><td>'eJyLjlZ3hANPW3UdhWiEiEeyBbpIqq-teiwYAACyGw9
K'</td></tr><tr valign="top"
align="left"><th>__ac_name</th><td>'wwf'</td></tr><tr valign="top"
align="left"><th>dtpref_cols</th><td>'85'</td></tr><tr valign="top"
align="left"><th>__cp</th><td>'x%DA%D3%60b%60%60%C8%04b%86hF%20%A1%C1%0C%24%
8AA%DCb%90DiA%B1%28%98JI%2CI%8DON%2CI%CC%C9O%F7%CCKI%ADH-%06%00%DC%9F%0B%FD'
</td></tr><tr valign="top"
align="left"><th>dtpref_rows</th><td>'29'</td></tr></table><h3>lazy
items</h3><table><tr valign="top"
align="left"><th>SESSION</th><td>&lt;Python Method object at
017F08A0&gt;</td></tr></table><h3>other</h3><table><tr valign="top"
align="left"><th>remote_obj_url</th><td>'http://localhost/up/Members/sgu/t=
es
tivo'</td></tr><tr valign="top"
align="left"><th>home_url</th><td>'http://localhost/up/Members/sgu'</td></tr
><tr valign="top" align="left"><th>dtpref_rows</th><td>'29'</td></tr><tr
valign="top" align="left"><th>channelContext</th><td>''</td></tr><tr
valign="top" align="left"><th>topic_id</th><td>None</td></tr><tr
valign="top" align="left"><th>__ac_name</th><td>'wwf'</td></tr><tr
valign="top" align="left"><th>dtpref_cols</th><td>'85'</td></tr><tr
valign="top"
align="left"><th>BASE3</th><td>'http://localhost/up/update_catalogIndexes'=
</
td></tr><tr valign="top"
align="left"><th>URLPATH0</th><td>'/up/update_catalogIndexes'</td></tr><tr
valign="top" align="left"><th>BASE1</th><td>'http://localhost'</td></tr><tr
valign="top" align="left"><th>BASE0</th><td>'http://localhost'</td></tr><tr
valign="top"
align="left"><th>SERVER_URL</th><td>'http://localhost'</td></tr><tr
valign="top" align="left"><th>member</th><td>''</td></tr><tr valign="top"
align="left"><th>folderish</th><td>0</td></tr><tr valign="top"
align="left"><th>AUTHENTICATED_USER</th><td>gregweb</td></tr><tr
valign="top"
align="left"><th>TraversalRequestNameStack</th><td>[]</td></tr><tr
valign="top" align="left"><th>obj</th><td>&lt;Document instance at
02440580&gt;</td></tr><tr valign="top"
align="left"><th>home_urls</th><td>{'wwf':
'http://localhost/up/Members/wwf', 'sgu':
'http://localhost/up/Members/sgu'}</td></tr><tr valign="top"
align="left"><th>cnt</th><td>4</td></tr><tr valign="top"
align="left"><th>tree-s</th><td>'eJyLjlZ3hANPW3UdhWiEiEeyBbpIqq-teiwYAACyGw9
K'</td></tr><tr valign="top"
align="left"><th>AUTHENTICATION_PATH</th><td>''</td></tr><tr valign="top"
align="left"><th>topicContext</th><td>''</td></tr><tr valign="top"
align="left"><th>__cp</th><td>'x%DA%D3%60b%60%60%C8%04b%86hF%20%A1%C1%0C%24%
8AA%DCb%90DiA%B1%28%98JI%2CI%8DON%2CI%CC%C9O%F7%CCKI%ADH-%06%00%DC%9F%0B%FD'
</td></tr><tr valign="top"
align="left"><th>previous_creator</th><td>'None'</td></tr><tr valign="top"
align="left"><th>msg</th><td>[]</td></tr><tr valign="top"
align="left"><th>wizard_available</th><td>0</td></tr><tr valign="top"
align="left"><th>URL0</th><td>'http://localhost/up/update_catalogIndexes'<=
/t
d></tr><tr valign="top"
align="left"><th>URL1</th><td>'http://localhost/up'</td></tr><tr
valign="top" align="left"><th>previous_date</th><td>'None'</td></tr><tr
valign="top"
align="left"><th>obj_url</th><td>'http://localhost/up/Members/sgu/testivo'=
</
td></tr><tr valign="top"
align="left"><th>URL2</th><td>'http://localhost'</td></tr><tr valign="top"
align="left"><th>top_id</th><td>'update_catalogIndexes'</td></tr><tr
valign="top" align="left"><th>PUBLISHED</th><td>&lt;ExternalMethod instance
at 019D1CC0&gt;</td></tr><tr valign="top"
align="left"><th>URL</th><td>'http://localhost/up/update_catalogIndexes'</=
td
></tr><tr valign="top"
align="left"><th>BASE2</th><td>'http://localhost/up'</td></tr><tr
valign="top"
align="left"><th>rc_object</th><td>'rc_portal_pages'</td></tr><tr
valign="top" align="left"><th>help_available</th><td>0</td></tr><tr
valign="top" align="left"><th>memberContext</th><td>''</td></tr><tr
valign="top" align="left"><th>channel_subj</th><td>0</td></tr><tr
valign="top"
align="left"><th>URL0</th><td>http://localhost/up/update_catalogIndexes</t=
d>
</tr><tr valign="top"
align="left"><th>URL1</th><td>http://localhost/up</td></tr><tr valign="top"
align="left"><th>URL2</th><td>http://localhost</td></tr><tr valign="top"
align="left"><th>BASE0</th><td>http://localhost</td></tr><tr valign="top"
align="left"><th>BASE1</th><td>http://localhost</td></tr><tr valign="top"
align="left"><th>BASE2</th><td>http://localhost/up</td></tr><tr
valign="top"
align="left"><th>BASE3</th><td>http://localhost/up/update_catalogIndexes</=
td
></tr></table><h3>environ</h3><table><tr valign="top"
align="left"><th>HTTP_ACCEPT_ENCODING</th><td>'gzip'</td></tr><tr
valign="top"
align="left"><th>channel.creation_time</th><td>1019733919</td></tr><tr
valign="top"
align="left"><th>HTTP_REFERER</th><td>'http://localhost/up/update_catalogI=
nd
exes/manage_main'</td></tr><tr valign="top"
align="left"><th>SERVER_PROTOCOL</th><td>'HTTP/1.0'</td></tr><tr
valign="top" align="left"><th>SERVER_PORT</th><td>'80'</td></tr><tr
valign="top"
align="left"><th>PATH_INFO</th><td>'/up/update_catalogIndexes'</td></tr><tr
valign="top" align="left"><th>HTTP_HOST</th><td>'localhost'</td></tr><tr
valign="top" align="left"><th>REQUEST_METHOD</th><td>'GET'</td></tr><tr
valign="top"
align="left"><th>PATH_TRANSLATED</th><td>'\\up\\update_catalogIndexes'</td><
/tr><tr valign="top" align="left"><th>SCRIPT_NAME</th><td>''</td></tr><tr
valign="top" align="left"><th>SERVER_SOFTWARE</th><td>'Zope/(Zope 2.5.0
(binary release, python 2.1, win32-x86), python 2.1.2, win32)
ZServer/1.1b1'</td></tr><tr valign="top"
align="left"><th>HTTP_ACCEPT_LANGUAGE</th><td>'de-CH,en'</td></tr><tr
valign="top"
align="left"><th>HTTP_ACCEPT_CHARSET</th><td>'iso-8859-1,*,utf-8'</td></tr><
tr valign="top" align="left"><th>HTTP_ACCEPT</th><td>'image/gif,
image/x-xbitmap, image/jpeg, image/pjpeg, image/png, */*'</td></tr><tr
valign="top" align="left"><th>REMOTE_ADDR</th><td>'127.0.0.1'</td></tr><tr
valign="top" align="left"><th>HTTP_COOKIE</th><td>'dtpref_rows="29";
dtpref_cols="85"; __ac_name="wwf";
__cp="x%DA%D3%60b%60%60%C8%04b%86hF%20%A1%C1%0C%24%8AA%DCb%90DiA%B1%28%98JI%
2CI%8DON%2CI%CC%C9O%F7%CCKI%ADH-%06%00%DC%9F%0B%FD";
tree-s="eJyLjlZ3hANPW3UdhWiEiEeyBbpIqq-teiwYAACyGw9K"'</td></tr><tr
valign="top"
align="left"><th>SERVER_NAME</th><td>'192.168.0.10'</td></tr><tr
valign="top"
align="left"><th>GATEWAY_INTERFACE</th><td>'CGI/1.1'</td></tr><tr
valign="top" align="left"><th>HTTP_USER_AGENT</th><td>'Mozilla/4.76 [en]
(WinNT; U)'</td></tr><tr valign="top"
align="left"><th>CONNECTION_TYPE</th><td>'Keep-Alive'</td></tr></table>),
{}, None))
  File F:\user\greg\data\zope_test\Extensions\update_catalogIndexes.py,
line 31, in update_catalogIndexes
    (Object: up)
  File D:\prog\zope_test\lib\python\Products\ZCatalog\ZCatalog.py, line
455, in manage_reindexIndex
    (Object: portal_catalog)
  File D:\prog\zope_test\lib\python\Products\ZCatalog\ZCatalog.py, line
441, in reindexIndex
    (Object: portal_catalog)
  File F:\user\greg\data\zope_test\Products\CMFCore\CatalogTool.py, line
212, in catalog_object
    (Object: portal_catalog)
  File D:\prog\zope_test\lib\python\Products\ZCatalog\ZCatalog.py, line
480, in catalog_object
    (Object: portal_catalog)
  File D:\prog\zope_test\lib\python\Products\ZCatalog\Catalog.py, line 367,
in catalogObject
  File
D:\prog\zope_test\lib\python\Products\PluginIndexes\TextIndex\TextIndex.py,
line 312, in index_object
    (Object: SearchableText)
TypeError: (see above)

Greg

_____________________________________
Grégoire Weber
mailto:gregoire.weber@switzerland.org