source: products/quintagroup.ploneformgen.readonlystringfield/trunk/quintagroup/ploneformgen/readonlystringfield/Extensions/Install.py

Last change on this file was 827, checked in by mylan, 17 years ago

Fix getActionById deprecation warning on publishing comment for Plone-2.5

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