1 """
2 $Id: platecom.langview.Extensions.install-pysrc.html 236 2008-06-10 20:28:23Z crocha $
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
15 from platecom.langview.config import *
16
18 """
19 Method to install dependencies...
20 @type portal: PloneSite
21 @param portal: The Plone site object
22 @type out: StringIO
23 @param out: The object to append the output
24
25 @rtype: StringIO
26 @return: Messages from the GS process
27
28 some tests here...
29 >>> from icsemantic.langfallback.config import *
30 >>> qi = portal.portal_quickinstaller
31 >>> installed = [ prod['id'] for prod in qi.listInstalledProducts() ]
32 >>> for dependency in DEPENDENCIES:
33 ... dependency in installed
34 True
35
36 """
37
38
39
40 quickinstaller = portal.portal_quickinstaller
41 for dependency in DEPENDENCIES:
42 print >> out, "Installing dependency %s:" % dependency
43 quickinstaller.installProduct(dependency)
44
45 return out
46
48 """
49 Method to install GS profiles...
50 @type portal: PloneSite
51 @param portal: The Plone site object
52 @type out: StringIO
53 @param out: The object to append the output
54
55 @rtype: StringIO
56 @return: Messages from the GS process
57
58 some tests here...
59 >>> from icsemantic.langfallback.config import *
60 >>> psetup = self.portal.portal_setup
61
62 just test we have registered the profile...
63 >>> profilename = PROJECTNAME + ':default'
64 >>> PACKAGENAME in [profile['product'] for profile in psetup.listProfileInfo()]
65 True
66 >>> profilename in [profile['id'] for profile in psetup.listProfileInfo()]
67 True
68
69 now we can test some stuff modified but that template...
70 >>> memberdata = self.portal.portal_memberdata
71 >>> [property for property in memberdata.propertyMap() if property['id'] == 'icsemantic.langfallback.language']
72 [{'type':...'lines', 'id': 'platecom.language'}]
73
74 """
75
76 setup_tool = getToolByName(portal, 'portal_setup')
77 profile_name = 'profile-' + PROJECTNAME + ':default'
78 if shasattr(setup_tool, 'runAllImportStepsFromProfile'):
79
80 print >> out, setup_tool.runAllImportStepsFromProfile(profile_name)
81 else:
82
83
84
85 old_context = setup_tool.getImportContextID()
86 print >> out, setup_tool.setImportContext(profile_name)
87 print >> out, setup_tool.runAllImportSteps()
88 print >> out, setup_tool.setImportContext(old_context)
89
90 return out
91
93 """
94 External module to install the product...
95 @type self: PloneSite
96 @param self: The Plone site object
97
98 @rtype: StringIO
99 @return: Messages from the install process
100
101 some tests here...
102 >>> from icsemantic.langfallback.config import *
103 >>> qi = self.portal.portal_quickinstaller
104 >>> installed = [ prod['id'] for prod in qi.listInstalledProducts() ]
105 >>> PACKAGENAME in installed
106 True
107
108 """
109 out = StringIO()
110 portal = getToolByName(self,'portal_url').getPortalObject()
111
112 print >> out, "Installing Dependencies"
113 res = install_dependencies( portal, out)
114 print >> out, res or 'no output'
115
116 print >> out, "Import GS Profiles"
117 res = import_gs_profiles( portal, out)
118 print >> out, res or 'no output'
119
120 return out.getvalue()
121
123 """
124 Method to uninstall GS profiles...
125 @type portal: PloneSite
126 @param portal: The Plone site object
127 @type out: StringIO
128 @param out: The object to append the output
129
130 @rtype: StringIO
131 @return: Messages from the GS process
132
133 some tests here...
134 >>> from icsemantic.langfallback.config import *
135 >>> psetup = self.portal.portal_setup
136
137 just test we have registered the profile...
138 >>> profilename = PROJECTNAME + ':default'
139 >>> PACKAGENAME in [profile['product'] for profile in psetup.listProfileInfo()]
140 True
141 >>> profilename in [profile['id'] for profile in psetup.listProfileInfo()]
142 True
143
144 now we can test some stuff modified but that template...
145 >>> memberdata = self.portal.portal_memberdata
146 >>> [property for property in memberdata.propertyMap() if property['id'] == 'icsemantic.langfallback.language']
147 []
148
149 """
150
151 setup_tool = getToolByName(portal, 'portal_setup')
152 profile_name = 'profile-' + PROJECTNAME + ':uninstall'
153 if shasattr(setup_tool, 'runAllImportStepsFromProfile'):
154
155 print >> out, setup_tool.runAllImportStepsFromProfile(profile_name)
156 else:
157
158
159
160 old_context = setup_tool.getImportContextID()
161 print >> out, setup_tool.setImportContext(profile_name)
162 print >> out, setup_tool.runAllImportSteps()
163 print >> out, setup_tool.setImportContext(old_context)
164
165 return out
166
168 """
169 External module to uninstall the product...
170 @type self: PloneSite
171 @param self: The Plone site object
172
173 @rtype: StringIO
174 @return: Messages from the install process
175
176 some tests here...
177 >>> from icsemantic.langfallback.config import *
178 >>> qi = self.portal.portal_quickinstaller
179 >>> installed = [ prod['id'] for prod in qi.listInstalledProducts() ]
180 >>> PACKAGENAME in installed
181 True
182
183 >>> qi.uninstallProducts((PACKAGENAME,))
184 >>> installed = [ prod['id'] for prod in qi.listInstalledProducts() ]
185 >>> PACKAGENAME in installed
186 False
187
188 """
189 out = StringIO()
190 portal = getToolByName(self,'portal_url').getPortalObject()
191
192 print >> out, "Uninstalling"
193
194 print >> out, "UnImport GS Profiles"
195 res = unimport_gs_profiles( portal, out)
196 print >> out, res or 'no output'
197
198 return out.getvalue()
199