source: products/quintagroup.plonegooglesitemaps/tags/1.2/quintagroup/plonegooglesitemaps/Extensions/Install.py

Last change on this file was 2384, checked in by mylan, 11 years ago

#250: Fixed and added test for reinstallation

  • Property svn:eol-style set to native
File size: 1.6 KB
Line 
1import logging
2from Products.CMFCore.utils import getToolByName
3from Products.GenericSetup.upgrade import _upgrade_registry
4
5logger = logging.getLogger("quintagroup.plonegooglesitemaps")
6PROFILE = "profile-quintagroup.plonegooglesitemaps:default"
7
8def install(self, reinstall=False):
9    """ Install skin with GenericSetup install profile
10    """
11    ps = getToolByName(self, 'portal_setup')
12    mtool = getToolByName(self, 'portal_migration')
13    plone_version = mtool.getFileSystemVersion()
14    isPlone3 = plone_version.startswith('3')
15    isPlone4 = plone_version.startswith('4')
16
17    if reinstall and (isPlone3 or isPlone4):
18        step = None
19        profile_id = 'quintagroup.plonegooglesitemaps:default'
20        steps_to_run = [s['id'] for s in ps.listUpgrades(profile_id, show_old=False)]
21        for step_id in steps_to_run:
22            step = _upgrade_registry.getUpgradeStep(profile_id, step_id)
23            step.doStep(ps)
24            msg = "Ran upgrade step %s for profile %s" % (step.title, profile_id)
25            logger.log(logging.INFO, msg)
26        # We update the profile version to the last one we have reached
27        # with running an upgrade step.
28        if step and step.dest is not None and step.checker is None:
29           ps.setLastVersionForProfile(profile_id, step.dest)
30        return "Ran all reinstall steps."
31
32    if (isPlone3 or isPlone4):
33        # if this is plone 3.x
34        (ps.aq_base).__of__(self).runAllImportStepsFromProfile(PROFILE)
35    else:
36        active_context_id = ps.getImportContextID()
37        ps.setImportContext(PROFILE)
38        ps.runAllImportSteps()
39        ps.setImportContext(active_context_id)
Note: See TracBrowser for help on using the repository browser.