source: products/qTrackSpam/trunk/Extensions/Install.py @ 1552

Last change on this file since 1552 was 1, checked in by myroslav, 14 years ago

Building directory structure

  • Property svn:eol-style set to native
File size: 2.3 KB
Line 
1from Products.Archetypes.public import listTypes
2from Products.Archetypes.Extensions.utils import installTypes, install_subskin
3from Products.CMFCore import CMFCorePermissions
4from Products.CMFCore.utils import getToolByName
5from StringIO import StringIO
6import sys
7
8from Products.qTrackSpam.config import *
9
10def install(self):
11    """ install product """
12    out = StringIO();
13    portal = getToolByName(self,'portal_url').getPortalObject()
14    installTypes(self, out, listTypes(PROJECTNAME), PROJECTNAME)
15    install_subskin(self, out, GLOBALS)
16    install_configlet(self, out)
17    try:
18        portal.manage_addProduct[PROJECTNAME].manage_addTool(TOOL_METATYPE)
19    except:
20        # heuristics for testing if an instance with the same name already exists
21        # only this error will be swallowed.
22        # Zope raises in an unelegant manner a 'Bad Request' error
23        e=sys.exc_info()
24        if e[0] != 'Bad Request':
25            raise
26
27
28
29    print >> out, "Successfully installed %s." % PROJECTNAME
30    return out.getvalue()
31
32def uninstall(self):
33    """ uninstall product """
34    out = StringIO()
35    control_panel = getToolByName(self, 'portal_controlpanel', None)
36    actions = control_panel._cloneActions()
37    res = [a.id for a in actions if a.id == PROJECTNAME]
38    for i in res:
39        control_panel.unregisterConfiglet(i)
40        out.write('Removed configlet %s\n' % i)
41
42    print >> out, "Successfully uninstalled %s." % PROJECTNAME
43    return out.getvalue()
44
45def install_configlet(self, out):
46    control_panel=getToolByName(self,'portal_controlpanel')
47    control_panel.registerConfiglet(PROJECTNAME,
48                                    'BlackList Importer',
49                                    'string:${portal_url}/prefs_blacklist_importer',
50                                     permission = 'Manage Portal',
51                                     category   = 'Products',
52                                    )
53    control_panel.registerConfiglet(PROJECTNAME,
54                                    'Clean TrackBacks',
55                                    'string:${portal_url}/prefs_clean_trackbacks',
56                                     permission = 'Manage Portal',
57                                     category   = 'Products',
58                                    )
59    print >> out, "Installed configlet.,,"
Note: See TracBrowser for help on using the repository browser.