1 """
2 Metodos de install para icsemantic.core
3
4 @author: Juan Pablo Gimenez
5 @contact: jpg@rcom.com.ar
6 """
7 __author__ = """Juan Pablo Gimenez <jpg@rcom.com.ar>"""
8 __docformat__ = 'plaintext'
9
10 from StringIO import StringIO
11
12 from Products.CMFCore.utils import getToolByName
13 from Products.Archetypes.utils import shasattr
14 from Products.Archetypes.Extensions.utils import install_subskin
15
16 from platecom.utils.config import *
17
19 """
20 Method to install platecom user properties...
21 @type: portal: PloneSite
22 @type out: StringIO
23
24 @rtype: StringIO
25 @return: Messages from the GS process
26 """
27 configTool=getToolByName(portal,'portal_controlpanel',None)
28 if configTool:
29 for conf in CONFIGLETS:
30 configTool.registerConfiglet(**conf)
31 out.write('Added configlet %s\n' % conf['id'])
32
33 return out
34
36 """
37 Method to uninstall platecom user properties...
38 @type: portal: PloneSite
39 @type out: StringIO
40
41 @rtype: StringIO
42 @return: Messages from the GS process
43 """
44 configTool=getToolByName(portal,'portal_controlpanel')
45 if configTool:
46 for conf in CONFIGLETS:
47 configTool.unregisterConfiglet(conf['id'])
48 out.write('Removed configlet %s\n' % conf['id'])
49
50 return out
51
53 """
54 Method to install dependencies...
55 @type portal: PloneSite
56 @param portal: The Plone site object
57 @type out: StringIO
58 @param out: The object to append the output
59
60 @rtype: StringIO
61 @return: Messages from the GS process
62
63 some tests here...
64
65 """
66
67
68
69 quickinstaller = portal.portal_quickinstaller
70 for dependency in DEPENDENCIES:
71 print >> out, "Installing dependency %s:" % dependency
72 quickinstaller.installProduct(dependency)
73
74 return out
75
77 """
78 Method to install GS profiles...
79 @type portal: PloneSite
80 @param portal: The Plone site object
81 @type out: StringIO
82 @param out: The object to append the output
83
84 @rtype: StringIO
85 @return: Messages from the GS process
86
87 some tests here...
88 >>> from icsemantic.core.config import *
89 >>> psetup = self.portal.portal_setup
90
91 just test we have registered the profile...
92 >>> profilename = PROJECTNAME + ':default'
93 >>> PACKAGENAME in [profile['product'] for profile in psetup.listProfileInfo()]
94 True
95 >>> profilename in [profile['id'] for profile in psetup.listProfileInfo()]
96 True
97
98 now we can test some stuff modified but that template...
99 >>> 'icSemantic' in [ai.getTitle() for ai in portal.portal_actionicons.listActionIcons()]
100 True
101
102 No se porque este no anda, anda bien en el test funcional...
103 >>> # [ai['name'] for ai in portal.portal_controlpanel.listActionInfos()] True
104
105
106 """
107
108 setup_tool = getToolByName(portal, 'portal_setup')
109 profile_name = 'profile-' + PROJECTNAME + ':default'
110 if shasattr(setup_tool, 'runAllImportStepsFromProfile'):
111
112 print >> out, setup_tool.runAllImportStepsFromProfile(profile_name)
113 else:
114
115
116
117 old_context = setup_tool.getImportContextID()
118 print >> out, setup_tool.setImportContext(profile_name)
119 print >> out, setup_tool.runAllImportSteps()
120 print >> out, setup_tool.setImportContext(old_context)
121
122 return out
123
125 """
126 External module to install the product...
127 @type self: PloneSite
128 @param self: The Plone site object
129
130 @rtype: StringIO
131 @return: Messages from the install process
132
133 some tests here...
134 >>> from icsemantic.core.config import *
135 >>> qi = self.portal.portal_quickinstaller
136 >>> installed = [ prod['id'] for prod in qi.listInstalledProducts() ]
137 >>> PACKAGENAME in installed
138 True
139
140 """
141 out = StringIO()
142 portal = getToolByName(self,'portal_url').getPortalObject()
143
144 install_subskin(self, out, GLOBALS)
145
146 print >> out, "Installing Dependencies"
147 res = install_dependencies( portal, out)
148 print >> out, res or 'no output'
149
150 print >> out, "Installing Configlets"
151 res = install_configlets( portal, out)
152 print >> out, res or 'no output'
153
154 print >> out, "Import GS Profiles"
155 res = import_gs_profiles( portal, out)
156 print >> out, res or 'no output'
157
158 return out.getvalue()
159
161 """
162 Method to uninstall GS profiles...
163 @type portal: PloneSite
164 @param portal: The Plone site object
165 @type out: StringIO
166 @param out: The object to append the output
167
168 @rtype: StringIO
169 @return: Messages from the GS process
170
171 some tests here...
172 >>> from icsemantic.core.config import *
173 >>> psetup = self.portal.portal_setup
174
175 just test we have registered the profile...
176 >>> profilename = PROJECTNAME + ':default'
177 >>> PACKAGENAME in [profile['product'] for profile in psetup.listProfileInfo()]
178 True
179 >>> profilename in [profile['id'] for profile in psetup.listProfileInfo()]
180 True
181
182 now we can test some stuff modified but that template...
183
184 """
185
186 setup_tool = getToolByName(portal, 'portal_setup')
187 profile_name = 'profile-' + PROJECTNAME + ':uninstall'
188 if shasattr(setup_tool, 'runAllImportStepsFromProfile'):
189
190 print >> out, setup_tool.runAllImportStepsFromProfile(profile_name)
191 else:
192
193
194
195 old_context = setup_tool.getImportContextID()
196 print >> out, setup_tool.setImportContext(profile_name)
197 print >> out, setup_tool.runAllImportSteps()
198 print >> out, setup_tool.setImportContext(old_context)
199
200 return out
201
203 """
204 External module to uninstall the product...
205 @type self: PloneSite
206 @param self: The Plone site object
207
208 @rtype: StringIO
209 @return: Messages from the install process
210
211 some tests here...
212 >>> from icsemantic.core.config import *
213 >>> qi = self.portal.portal_quickinstaller
214 >>> installed = [ prod['id'] for prod in qi.listInstalledProducts() ]
215 >>> PACKAGENAME in installed
216 True
217
218 >>> self.setRoles(['Manager',])
219 >>> qi.uninstallProducts((PACKAGENAME,))
220 >>> installed = [ prod['id'] for prod in qi.listInstalledProducts() ]
221 >>> PACKAGENAME in installed
222 False
223
224 """
225 out = StringIO()
226 portal = getToolByName(self,'portal_url').getPortalObject()
227
228 print >> out, "Uninstalling"
229
230 print >> out, "Uninstalling Configlets"
231 res = uninstall_configlets( portal, out)
232 print >> out, res or 'no output'
233
234 print >> out, "UnImport GS Profiles"
235 res = unimport_gs_profiles( portal, out)
236 print >> out, res or 'no output'
237
238 return out.getvalue()
239