source: products/qPingTool/tags/0.2/Extensions/Install.py @ 1

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

Building directory structure

File size: 3.1 KB
Line 
1from StringIO import StringIO
2from Products.Archetypes.public import listTypes
3from Products.Archetypes.Extensions.utils import installTypes, install_subskin
4from Products.CMFCore.CMFCorePermissions import ManagePortal
5from Products.CMFCore.utils import getToolByName
6from Products.qPingTool.config import *
7from Products.qPingTool import PingTool
8from Products.CMFCore.TypesTool import ContentFactoryMetadata
9from Products.CMFCore.utils import getToolByName
10from Products.CMFPlone.migrations.migration_util import safeEditProperty
11
12
13
14def install(self):
15    out = StringIO()
16
17    installTypes(self, out, listTypes(PROJECTNAME), PROJECTNAME)
18    portal = getToolByName(self, 'portal_url').getPortalObject()
19    if not hasattr(portal, TOOL_ID):
20        portal.invokeFactory(id=TOOL_ID, type_name='PingTool')
21
22    # Add PortalActions Tool Configlet. Delete old version before adding, if exist one.
23    controlpanel_tool = getToolByName(self, 'portal_controlpanel')
24    controlpanel_tool.unregisterConfiglet(TOOL_ID)
25    controlpanel_tool.registerConfiglet(id=TOOL_ID, name='Ping Tool', category='Products',
26                                        action='string:${portal_url}/'+TOOL_ID+'/folder_contents',
27                                        appId=PROJECTNAME,  permission=ManagePortal, imageUrl='group.gif')
28
29    # Add 'portal_actionstool' to action provider list, if not yet exist
30    action_tool = getToolByName(portal, 'portal_actions')
31    if TOOL_ID not in action_tool.listActionProviders():
32        action_tool.addActionProvider(TOOL_ID)
33
34
35    install_subskin(self,out,GLOBALS)
36   
37
38    for site in SITES_LIST:
39        portal.portal_pingtool.invokeFactory(id = site[0], type_name = "PingInfo", title = site[1],url = site[2])
40
41    pp = getToolByName(self,'portal_properties')
42    np = getattr(pp,'navtree_properties')
43    meta_types = list(np.getProperty('metaTypesNotToList'))
44    if 'PingTool' not in meta_types:
45        meta_types.append('PingTool')
46    safeEditProperty(np,'metaTypesNotToList', meta_types, 'lines')
47
48
49   
50    print >> out, "\nSuccessfully installed %s." % PROJECTNAME
51    return out.getvalue()
52
53def uninstall(portal):
54    action_tool = getToolByName(portal, 'portal_actions')
55    # Delete ActionProvider
56    action_tool.deleteActionProvider(TOOL_ID)
57
58    controlpanel_tool = getToolByName(portal, 'portal_controlpanel')
59    controlpanel_tool.unregisterConfiglet(TOOL_ID)
60
61    removeSkin(portal, ('ping_tool.pt',))
62
63    #wf_tool=getToolByName(self, 'portal_workflow')
64    #wf=wf_tool.plone_workflow
65    #tdef = wf.transitions['publish']
66    #tdef.after_script_name=None
67
68
69    return '%s actionProvider successfully uninstalled' % TOOL_ID
70
71def removeSkin(self, skins = []):
72    if skins:
73        skinstool = getToolByName(self, 'portal_skins')
74        for skinName in skinstool.getSkinSelections():
75            path = skinstool.getSkinPath(skinName)
76            path = [i.strip() for i in  path.split(',')]
77            for s in skins:
78                if s in path:
79                    path.remove(s)
80            path = ','.join(path)
81            skinstool.addSkinSelection(skinName, path)
Note: See TracBrowser for help on using the repository browser.