source: products/quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/setuphandlers.py @ 1727

Last change on this file since 1727 was 1727, checked in by mylan, 14 years ago

Add catalog updating on product installation

  • Property svn:eol-style set to native
File size: 826 bytes
Line 
1import logging
2import time
3from Products.CMFCore.utils import getToolByName
4from Products.CMFCore.Expression import Expression
5
6from Products.ZCatalog.ProgressHandler import ZLogHandler
7
8logger = logging.getLogger('quintagroup.seoptimizer')
9
10def updateCatalog(context):
11    """ Update Catalog to collect data for canonical_path metadata.
12    """
13    if context.readDataFile('plonegooglesitemap_install.txt') is None:
14        return
15
16    site = context.getSite()
17    catalog = getToolByName(site, 'portal_catalog')
18
19    elapse = time.time()
20    c_elapse = time.clock()
21    print "Start of catalog rebuilding : %s" % c_elapse
22    catalog.refreshCatalog(clear=1)
23    elapse = time.time() - elapse
24    c_elapse = time.clock() - c_elapse
25    print "Catalog Rebuild\nTotal time: %s\nTotal CPU time: %s" % (elapse, c_elapse) 
26
27   
28
Note: See TracBrowser for help on using the repository browser.