[865] | 1 | # -*- coding: utf-8 -*- |
---|
| 2 | |
---|
| 3 | import transaction |
---|
| 4 | from Products.CMFCore.utils import getToolByName |
---|
| 5 | |
---|
| 6 | PRODUCT_DEPENDENCIES = () |
---|
| 7 | |
---|
| 8 | EXTENSION_PROFILES = ( |
---|
| 9 | 'quintagroup.plonetabs:default', |
---|
| 10 | ) |
---|
| 11 | |
---|
| 12 | UNINSTALL_PROFILES = ( |
---|
| 13 | 'quintagroup.plonetabs:uninstall', |
---|
| 14 | ) |
---|
| 15 | |
---|
[3402] | 16 | |
---|
[865] | 17 | def 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. |
---|
[3402] | 21 | |
---|
[865] | 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 |
---|
[3402] | 24 | precedence over extension profiles for the same product in |
---|
| 25 | portal_quickinstaller. |
---|
| 26 | |
---|
[865] | 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 | """ |
---|
[3402] | 31 | |
---|
[865] | 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() |
---|
[3402] | 42 | |
---|
[865] | 43 | for extension_id in EXTENSION_PROFILES: |
---|
[3402] | 44 | portal_setup.runAllImportStepsFromProfile('profile-%s' % extension_id, |
---|
| 45 | purge_old=False) |
---|
[865] | 46 | product_name = extension_id.split(':')[0] |
---|
| 47 | portal_quickinstaller.notifyInstalled(product_name) |
---|
| 48 | transaction.savepoint() |
---|
| 49 | |
---|
[3402] | 50 | |
---|
[865] | 51 | def uninstall(self): |
---|
| 52 | portal_setup = getToolByName(self, 'portal_setup') |
---|
| 53 | for extension_id in UNINSTALL_PROFILES: |
---|
[3402] | 54 | portal_setup.runAllImportStepsFromProfile('profile-%s' % extension_id, |
---|
| 55 | purge_old=False) |
---|
[865] | 56 | product_name = extension_id.split(':')[0] |
---|
| 57 | transaction.savepoint() |
---|