source: products/PloneSMSCommunicator/trunk/Extensions/Install.py @ 2284

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

Building directory structure

File size: 2.5 KB
Line 
1# Author: Melnychuk Taras
2# Contact: fenix@quintagroup.com
3# Date: $Date: 2005-12-23 11:42:10
4# Copyright: quintagroup.com
5
6"""
7This module is created for installing PloneSMSCommunicator tool to Plone site. It has such functions:
8
9     - `install`: this function sets all types in PloneSMSCommunicator tool, also install skin directory and other
10     - `install_configlet`: install configlet to portal control panel
11     - `remove_configlet`: remove configlet from portal control panel
12     - `uninstall`: uninstall all needed things
13
14"""
15__docformat__ = 'restructuredtext'
16
17
18from Products.Archetypes.Extensions.utils import installTypes, install_subskin
19from Products.Archetypes.public import listTypes
20from Products.CMFCore.utils import getToolByName
21from StringIO import StringIO
22import os
23
24from Products.PloneSMSCommunicator.PloneSMSCommunicator import PloneSMSCommunicator
25from Products.PloneSMSCommunicator.config import *
26
27def install_configlet(self, out):
28    """
29    install configlet to portal control panel
30    """
31    control_panel=getToolByName(self,'portal_controlpanel')
32    control_panel.registerConfiglet(PROJECTNAME,
33                                    'Portal SMS Communicator',
34                                    'string:${portal_url}/prefs_smsCommunicator_properties' ,
35                                     permission=SMSCOMMUNICATOR_MP,
36                                     imageUrl='link_icon.gif',
37                                     category='Products',
38                                    )
39    print >> out, "Installed configlet.,,"
40
41
42def remove_configlet(self, out):
43    """
44    remove configlet from portal control panel
45    """
46    control_panel=getToolByName(self,'portal_controlpanel')
47    control_panel.unregisterConfiglet(PROJECTNAME) 
48    print >> out, "Removed configlet.,,"
49
50def install(self):
51    """
52    this function sets all types in PloneSMSCommunicator tool, also install skin directory and other
53    """
54    out=StringIO();
55    installTypes(self, out, listTypes(PROJECTNAME), PROJECTNAME)
56    portal=getToolByName(self, 'portal_url').getPortalObject()
57
58    if COMMUNICATORID not in portal.objectIds():
59        addPloneTool=portal.manage_addProduct[PROJECTNAME].manage_addTool(PROJECTNAME)
60
61    install_subskin(self, out, GLOBALS)
62    install_configlet(self, out)
63
64    print >> out, "Successfully installed %s." % PROJECTNAME
65    return out.getvalue()
66
67def uninstall(self):
68    """
69    uninstall all needed things
70    """
71    out = StringIO()
72    remove_configlet(self, out)
73    print >> out, "Successfully uninstalled %s." % PROJECTNAME
74    return out.getvalue()
Note: See TracBrowser for help on using the repository browser.