| 1 | from Products.CMFCore.utils import getToolByName |
|---|
| 2 | from Products.GenericSetup.upgrade import _upgrade_registry |
|---|
| 3 | |
|---|
| 4 | PROFILE = "profile-quintagroup.plonegooglesitemaps:default" |
|---|
| 5 | |
|---|
| 6 | def 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) |
|---|