source: products/quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/Extensions/Install.py @ 2376

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

Added upgrade steps from 1.0 to 1.1 and from 1.1 to 1.2 versions

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