source: products/quintagroup.plonegooglesitemaps/branches/1.1_fix/quintagroup/plonegooglesitemaps/setuphandlers.py

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

Add flag for turn-on/off catalog updating. By default set to False. Update INSTALLATION file with cataog updating instructions

  • Property svn:eol-style set to native
File size: 904 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
8from config import UPDATE_CATALOG
9
10logger = logging.getLogger('quintagroup.seoptimizer')
11
12def updateCatalog(context):
13    """ Update Catalog to collect data for canonical_path metadata.
14    """
15    if not (context.readDataFile('plonegooglesitemap_install.txt') is not None \
16            and UPDATE_CATALOG):
17        return
18
19    site = context.getSite()
20    catalog = getToolByName(site, 'portal_catalog')
21
22    elapse = time.time()
23    c_elapse = time.clock()
24    print "Start of catalog rebuilding : %s" % c_elapse
25    catalog.refreshCatalog(clear=1)
26    elapse = time.time() - elapse
27    c_elapse = time.clock() - c_elapse
28    print "Catalog Rebuild\nTotal time: %s\nTotal CPU time: %s" % (elapse, c_elapse) 
29
30   
31
Note: See TracBrowser for help on using the repository browser.