Thank you, Maurits,

but or I'm missing something or the situation is quite inconsistent in my view.

I already noticed, while developing on Plone 2.1 and Plone 2.5 with Archetypes and ArchGenXml (AGX 1.4 and 1.5), that even for moderately complex indexes, like ZCTextIndex, the index tag in an AGX class diagram and the index attribute in a field of an AT schema didn't result, during the product installation, in the creation of the corresponding index in the catalog.
I had to put code in Extensions/AppInstall.py to create ZCTextIndexes.
But, at least, those indexes weren't emptied (purged) at each reinstall of the product.

Now, in Plone 3, using AGX 2.3, at first sight the situation has improved significantly: - AGX creates a catalog.xml profile file, thus providing a declarative representation of the index definitions - GenericSetup is able, on install, to create the more common indexes; among them FieldIndex, KeywordIndex and ZCTextIndex (at least when specific options are not needed). But all this is wasted since the indexes defined are being emptied at each reinstall. I dont like tens of indexes indexing thousands of objects be reset at each reinstall. I cannot even follow your strategy (similar to my previous AppInstall strategy), since the catalog.xml file is there in the default profile.

What can I do? In order to follow your strategy (to do all in setuphandlers.py) I should: 1. not use AGX, or remove all index-related tags from the UML model of my products, or 2. patch AGX so that it doesn't generate the catalog.xml file, or remove the file in the script running AGX, or 3. patch the _importNode method of module exportimport.py in GenericSetup/ZCatalog to disable purging.
If I choose option 3., I recover the past behaviour.

Possibly I'm wrong, but I think that your post of March 2007, in section "3. Keeping an index", was suggesting a reasonable solution.

Best regard, Giovanni Toffoli

----- Original Message ----- From: "Maurits van Rees" <[email protected]>
To: <[email protected]>
Sent: Friday, February 13, 2009 5:00 PM
Subject: [Product-Developers] Re: How to import catalog.xml without emptyingthe indexes


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]


_______________________________________________
Product-Developers mailing list
[email protected]
http://lists.plone.org/mailman/listinfo/product-developers




_______________________________________________
Product-Developers mailing list
[email protected]
http://lists.plone.org/mailman/listinfo/product-developers

Reply via email to