[1] | 1 | # Author: Melnychuk Taras |
---|
| 2 | # Contact: fenix@quintagroup.com |
---|
| 3 | # Date: $Date: 2005-12-23 11:42:10 |
---|
| 4 | # Copyright: quintagroup.com |
---|
| 5 | |
---|
| 6 | """ |
---|
| 7 | This 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 | |
---|
| 18 | from Products.Archetypes.Extensions.utils import installTypes, install_subskin |
---|
| 19 | from Products.Archetypes.public import listTypes |
---|
| 20 | from Products.CMFCore.utils import getToolByName |
---|
| 21 | from StringIO import StringIO |
---|
| 22 | import os |
---|
| 23 | |
---|
| 24 | from Products.PloneSMSCommunicator.PloneSMSCommunicator import PloneSMSCommunicator |
---|
| 25 | from Products.PloneSMSCommunicator.config import * |
---|
| 26 | |
---|
| 27 | def 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 | |
---|
| 42 | def 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 | |
---|
| 50 | def 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 | |
---|
| 67 | def 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() |
---|