[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 | |
---|
[3437] | 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. |
---|
[3437] | 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 |
---|
[3437] | 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 | """ |
---|
[3437] | 31 | |
---|
[865] | 32 | portal_quickinstaller = getToolByName(self, 'portal_quickinstaller') |
---|
| 33 | portal_setup = getToolByName(self, 'portal_setup') |
---|
[3648] | 34 | portal_migration = getToolByName(self, 'portal_migration') |
---|
[3649] | 35 | |
---|
| 36 | # plone.app.kss dependency fix for plone >= 4.3 |
---|
| 37 | plone_version = portal_migration.coreVersions().get('Plone Instance', |
---|
| 38 | 'unknown') |
---|
| 39 | if plone_version.replace('.', '')[:2] >= '43': |
---|
[3648] | 40 | global PRODUCT_DEPENDENCIES |
---|
[3649] | 41 | PRODUCT_DEPENDENCIES += ('plone.app.kss', ) |
---|
[865] | 42 | |
---|
| 43 | for product in PRODUCT_DEPENDENCIES: |
---|
| 44 | if reinstall and portal_quickinstaller.isProductInstalled(product): |
---|
| 45 | portal_quickinstaller.reinstallProducts([product]) |
---|
| 46 | transaction.savepoint() |
---|
| 47 | if not portal_quickinstaller.isProductInstalled(product): |
---|
| 48 | portal_quickinstaller.installProduct(product) |
---|
| 49 | transaction.savepoint() |
---|
[3437] | 50 | |
---|
[865] | 51 | for extension_id in EXTENSION_PROFILES: |
---|
[3437] | 52 | portal_setup.runAllImportStepsFromProfile('profile-%s' % extension_id, |
---|
| 53 | purge_old=False) |
---|
[865] | 54 | product_name = extension_id.split(':')[0] |
---|
| 55 | portal_quickinstaller.notifyInstalled(product_name) |
---|
| 56 | transaction.savepoint() |
---|
| 57 | |
---|
[3437] | 58 | |
---|
[865] | 59 | def uninstall(self): |
---|
| 60 | portal_setup = getToolByName(self, 'portal_setup') |
---|
| 61 | for extension_id in UNINSTALL_PROFILES: |
---|
[3437] | 62 | portal_setup.runAllImportStepsFromProfile('profile-%s' % extension_id, |
---|
| 63 | purge_old=False) |
---|
[865] | 64 | transaction.savepoint() |
---|