[Product-Developers] Re: How to import catalog.xml without emptying the indexes
Maurits van Rees
m.van.rees at zestsoftware.nl
Fri Feb 13 16:00:43 UTC 2009
Hi Giovanni,
Giovanni Toffoli, on 2009-02-10:
> Two questions:
> 1.
> Anybody knows if during the last months the way genericsetup handles the
> index definitions has been improved, possibly by implementing some "keep" or
> "purge" attribute ?
> (see also the extensive discussion by Maurits van Rees at
> http://mail.zope.org/pipermail/zope-cmf/2007-March/025664.html )
There has been no change that I am aware of. I think the summary is
that comparing the xml settings with the current settings is doable
for simple indexes, but not for complex ones like TextIndexNG3; so
this is not likely to get fixed.
> 2.
> It is possible to know whether setuphandlers.py, is is being executed as
> result of an "install" or of a "reinstall" action ?
No. My current strategy is to do to it all in python code, in
setuphandlers.py:
========================================================
def add_catalog_indexes(site, logger):
"""Add our indexes to the catalog.
Doing it here instead of in profiles/default/catalog.xml means we
do not need to reindex those indexes after every reinstall.
"""
catalog = getToolByName(site, 'portal_catalog')
indexes = catalog.indexes()
wanted = (("getAssignees", "KeywordIndex"),
("getBookingDate", "DateIndex"),
("getBillableProject", "FieldIndex"),
)
for name, meta_type in wanted:
if name not in indexes:
catalog.addIndex(name, meta_type)
logger.info("Added %s for field %s.", meta_type, name)
========================================================
Cheers,
--
Maurits van Rees | http://maurits.vanrees.org/
Work | http://zestsoftware.nl/
"This is your day, don't let them take it away." [Barlow Girl]
More information about the Product-Developers
mailing list