source: products/quintagroup.plonecomments/trunk/quintagroup/plonecomments/setuphandlers.py @ 3116

Last change on this file since 3116 was 3116, checked in by kroman0, 13 years ago

Pyflakes and pep8 fixes #3

File size: 1.9 KB
Line 
1from Products.CMFCore.utils import getToolByName
2from quintagroup.plonecomments.config import LOGGER
3
4def install(context):
5
6    # Ordinarily, GenericSetup handlers check for the existence of XML files.
7    # Here, we are not parsing an XML file, but we use this text file as a
8    # flag to check that we actually meant for this import step to be run.
9    # The file is found in profiles/default.
10
11    if context.readDataFile('quintagroup.plonecomments_install.txt') is None:
12        return
13
14    # Add additional setup code here
15
16    portal = context.getSite()
17    logger = context.getLogger(LOGGER)
18
19    # Add 'DiscussionManagers' group
20    gtool = getToolByName(portal, 'portal_groups')
21    existing = gtool.listGroupIds()
22    if not 'DiscussionManager' in existing:
23        gtool.addGroup('DiscussionManager', roles=['DiscussionManager'])
24        logger.info('Added DiscussionManager group to portal_groups with '
25                    'DiscussionManager role.')
26
27    # Remove workflow-chain for Discussion Item
28    wf_tool = getToolByName(portal, 'portal_workflow')
29    wf_tool.setChainForPortalTypes(('Discussion Item',), [])
30    logger.info('Removed workflow chain for Discussion Item type.')
31
32def uninstall(context):
33
34    # Ordinarily, GenericSetup handlers check for the existence of XML files.
35    # Here, we are not parsing an XML file, but we use this text file as a
36    # flag to check that we actually meant for this import step to be run.
37    # The file is found in profiles/default.
38
39    if context.readDataFile('quintagroup.plonecomments_uninstall.txt') is None:
40        return
41
42    # Add additional setup code here
43
44    portal = context.getSite()
45    logger = context.getLogger(LOGGER)
46
47    portal_conf = getToolByName(portal, 'portal_controlpanel')
48    portal_conf.unregisterConfiglet('prefs_comments_setup_form')
49    logger.info('Unregister configlet prefs_comments_setup_form. ')
Note: See TracBrowser for help on using the repository browser.