source: products/quintagroup.plonetabs/trunk/quintagroup/plonetabs/Extensions/Install.py @ 3648

Last change on this file since 3648 was 3648, checked in by enkidu, 11 years ago

move dependency to Install.py and activate it only for plone vesrvions >= 4.3

  • Property svn:eol-style set to native
File size: 2.3 KB
Line 
1# -*- coding: utf-8 -*-
2
3import transaction
4from Products.CMFCore.utils import getToolByName
5
6PRODUCT_DEPENDENCIES = ()
7
8EXTENSION_PROFILES = (
9    'quintagroup.plonetabs:default',
10)
11
12UNINSTALL_PROFILES = (
13    'quintagroup.plonetabs:uninstall',
14)
15
16
17def install(self, reinstall=False):
18    """Install a set of products (which themselves may either use Install.py
19    or GenericSetup extension profiles for their configuration) and then
20    install a set of extension profiles.
21
22    One of the extension profiles we install is that of this product. This
23    works because an Install.py installation script (such as this one) takes
24    precedence over extension profiles for the same product in
25    portal_quickinstaller.
26
27    We do this because it is not possible to install other products during
28    the execution of an extension profile (i.e. we cannot do this during
29    the importVarious step for this profile).
30    """
31
32    portal_quickinstaller = getToolByName(self, 'portal_quickinstaller')
33    portal_setup = getToolByName(self, 'portal_setup')
34    portal_migration = getToolByName(self, 'portal_migration')
35   
36    # plone.app.kss dependency fix for plone >= 4.3
37    plone_version = portal_migration.coreVersions().get('Plone Instance', 'unknown')
38    if plone_version.replace('.','')[:2] >= '43':
39        global PRODUCT_DEPENDENCIES
40        PRODUCT_DEPENDENCIES += ('plone.app.kss',)
41
42    for product in PRODUCT_DEPENDENCIES:
43        if reinstall and portal_quickinstaller.isProductInstalled(product):
44            portal_quickinstaller.reinstallProducts([product])
45            transaction.savepoint()
46        if not portal_quickinstaller.isProductInstalled(product):
47            portal_quickinstaller.installProduct(product)
48            transaction.savepoint()
49
50    for extension_id in EXTENSION_PROFILES:
51        portal_setup.runAllImportStepsFromProfile('profile-%s' % extension_id,
52                                                  purge_old=False)
53        product_name = extension_id.split(':')[0]
54        portal_quickinstaller.notifyInstalled(product_name)
55        transaction.savepoint()
56
57
58def uninstall(self):
59    portal_setup = getToolByName(self, 'portal_setup')
60    for extension_id in UNINSTALL_PROFILES:
61        portal_setup.runAllImportStepsFromProfile('profile-%s' % extension_id,
62                                                  purge_old=False)
63        transaction.savepoint()
Note: See TracBrowser for help on using the repository browser.