1 | import transaction |
---|
2 | from Products.CMFCore.utils import getToolByName |
---|
3 | REQUIRED = 'quintagroup.captcha.core' |
---|
4 | |
---|
5 | |
---|
6 | def install(self): |
---|
7 | qi = getToolByName(self, 'portal_quickinstaller') |
---|
8 | # install required quintagroup.captcha.core product |
---|
9 | # BBB: Need to success installation in Plone<3.1 |
---|
10 | # (with GenericSetup < v1.4.2, where dependency |
---|
11 | # support was not yet implemented) |
---|
12 | if not REQUIRED in qi.listInstalledProducts(): |
---|
13 | qi.installProduct(REQUIRED) |
---|
14 | # install plonecaptchas |
---|
15 | gs = getToolByName(self, 'portal_setup') |
---|
16 | profile = 'profile-quintagroup.plonecaptchas:default' |
---|
17 | gs.runAllImportStepsFromProfile(profile) |
---|
18 | transaction.savepoint() |
---|
19 | |
---|
20 | |
---|
21 | def uninstall(self): |
---|
22 | portal_setup = getToolByName(self, 'portal_setup') |
---|
23 | profile = 'profile-quintagroup.plonecaptchas:uninstall' |
---|
24 | portal_setup.runAllImportStepsFromProfile(profile, purge_old=False) |
---|
25 | |
---|
26 | # BBB: Remove skin layers. Need for plone < 3.1 |
---|
27 | skin_tool = getToolByName(self, 'portal_skins') |
---|
28 | for skin in skin_tool.getSkinSelections(): |
---|
29 | path = [elem for elem in skin_tool.getSkinPath(skin).split(',')] |
---|
30 | for layer in ['captchas_discussion', 'captchas_sendto_form', |
---|
31 | 'captchas_join_form']: |
---|
32 | if layer in skin_tool.objectIds(): |
---|
33 | skin_tool.manage_delObjects(ids=[layer]) |
---|
34 | if layer in path: |
---|
35 | path.remove(layer) |
---|
36 | skin_path = ','.join(path) |
---|
37 | skin_tool.addSkinSelection(skin, skin_path) |
---|
38 | transaction.savepoint() |
---|