source: products/quintagroup.plonetabs/branches/tests/quintagroup/plonetabs/Extensions/Install.py @ 3403

Last change on this file since 3403 was 3403, checked in by potar, 8 years ago

Fixed code according with pylint, pyflakes

  • Property svn:eol-style set to native
File size: 2.0 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
35    for product in PRODUCT_DEPENDENCIES:
36        if reinstall and portal_quickinstaller.isProductInstalled(product):
37            portal_quickinstaller.reinstallProducts([product])
38            transaction.savepoint()
39        if not portal_quickinstaller.isProductInstalled(product):
40            portal_quickinstaller.installProduct(product)
41            transaction.savepoint()
42
43    for extension_id in EXTENSION_PROFILES:
44        portal_setup.runAllImportStepsFromProfile('profile-%s' % extension_id,
45                                                  purge_old=False)
46        product_name = extension_id.split(':')[0]
47        portal_quickinstaller.notifyInstalled(product_name)
48        transaction.savepoint()
49
50
51def uninstall(self):
52    portal_setup = getToolByName(self, 'portal_setup')
53    for extension_id in UNINSTALL_PROFILES:
54        portal_setup.runAllImportStepsFromProfile('profile-%s' % extension_id,
55                                                  purge_old=False)
56        transaction.savepoint()
Note: See TracBrowser for help on using the repository browser.