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