source: products/quintagroup.plonecaptchas/trunk/quintagroup/plonecaptchas/Extensions/Install.py @ 3215

Last change on this file since 3215 was 3215, checked in by vmaksymiv, 13 years ago

fixed layer uninstallation for plone<3.1

File size: 1.5 KB
Line 
1import transaction
2from Products.CMFCore.utils import getToolByName
3REQUIRED = 'quintagroup.captcha.core'
4
5
6def 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
21def 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()
Note: See TracBrowser for help on using the repository browser.