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 from Products.Archetypes.Extensions.utils import install_subskin
15
16 from platecom.langview.config import *
17
19 """
20 Method to install dependencies...
21 @type portal: PloneSite
22 @param portal: The Plone site object
23 @type out: StringIO
24 @param out: The object to append the output
25
26 @rtype: StringIO
27 @return: Messages from the GS process
28
29 some tests here...
30 >>> from icsemantic.langfallback.config import *
31 >>> qi = portal.portal_quickinstaller
32 >>> installed = [ prod['id'] for prod in qi.listInstalledProducts() ]
33 >>> DEPENDENCIES == [dependency for dependency in DEPENDENCIES if 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'] == 'platecom.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 install_subskin(self, out, GLOBALS)
113
114 print >> out, "Installing Dependencies"
115 res = install_dependencies( portal, out)
116 print >> out, res or 'no output'
117
118 print >> out, "Import GS Profiles"
119 res = import_gs_profiles( portal, out)
120 print >> out, res or 'no output'
121
122 return out.getvalue()
123
125 """
126 Method to uninstall GS profiles...
127 @type portal: PloneSite
128 @param portal: The Plone site object
129 @type out: StringIO
130 @param out: The object to append the output
131
132 @rtype: StringIO
133 @return: Messages from the GS process
134
135 some tests here...
136 >>> from icsemantic.langfallback.config import *
137 >>> psetup = self.portal.portal_setup
138
139 just test we have registered the profile...
140 >>> profilename = PROJECTNAME + ':default'
141 >>> PACKAGENAME in [profile['product'] for profile in psetup.listProfileInfo()]
142 True
143 >>> profilename in [profile['id'] for profile in psetup.listProfileInfo()]
144 True
145
146 now we can test some stuff modified but that template...
147 >>> memberdata = self.portal.portal_memberdata
148 >>> [property for property in memberdata.propertyMap() if property['id'] == 'icsemantic.langfallback.language']
149 []
150
151 """
152
153 setup_tool = getToolByName(portal, 'portal_setup')
154 profile_name = 'profile-' + PROJECTNAME + ':uninstall'
155 if shasattr(setup_tool, 'runAllImportStepsFromProfile'):
156
157 print >> out, setup_tool.runAllImportStepsFromProfile(profile_name)
158 else:
159
160
161
162 old_context = setup_tool.getImportContextID()
163 print >> out, setup_tool.setImportContext(profile_name)
164 print >> out, setup_tool.runAllImportSteps()
165 print >> out, setup_tool.setImportContext(old_context)
166
167 return out
168
170 """
171 External module to uninstall the product...
172 @type self: PloneSite
173 @param self: The Plone site object
174
175 @rtype: StringIO
176 @return: Messages from the install process
177
178 some tests here...
179 >>> from icsemantic.langfallback.config import *
180 >>> qi = self.portal.portal_quickinstaller
181 >>> installed = [ prod['id'] for prod in qi.listInstalledProducts() ]
182 >>> PACKAGENAME in installed
183 True
184
185 >>> qi.uninstallProducts((PACKAGENAME,))
186 >>> installed = [ prod['id'] for prod in qi.listInstalledProducts() ]
187 >>> PACKAGENAME in installed
188 False
189
190 """
191 out = StringIO()
192 portal = getToolByName(self,'portal_url').getPortalObject()
193
194 print >> out, "Uninstalling"
195
196 print >> out, "UnImport GS Profiles"
197 res = unimport_gs_profiles( portal, out)
198 print >> out, res or 'no output'
199
200 return out.getvalue()
201