root/Extensions/Install.py

Revision 4, 6.0 kB (checked in by matt_dorn@yahoo.com, 4 years ago)

0.3: Some final touch-ups before uploading

Line 
1 # File: Install.py
2 #
3 # Copyright (c) 2006 by Matt Dorn
4 # Generator: ArchGenXML Version 1.4.1
5 #            http://plone.org/products/archgenxml
6 #
7 # GNU General Public License (GPL)
8 #
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License
11 # as published by the Free Software Foundation; either version 2
12 # of the License, or (at your option) any later version.
13 #
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write to the Free Software
21 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 # 02110-1301, USA.
23 #
24
25 __author__ = """Matt Dorn <matt_dorn@yahoo.com>"""
26 __docformat__ = 'plaintext'
27
28
29 import os.path
30 import sys
31 from StringIO import StringIO
32 from sets import Set
33 from App.Common import package_home
34 from Products.CMFCore.utils import getToolByName
35 from Products.CMFCore.utils import manage_addTool
36 from Products.ExternalMethod.ExternalMethod import ExternalMethod
37 from zExceptions import NotFound, BadRequest
38
39 from Products.Archetypes.Extensions.utils import installTypes
40 from Products.Archetypes.Extensions.utils import install_subskin
41 from Products.Archetypes.config import TOOL_NAME as ARCHETYPETOOLNAME
42 from Products.Archetypes.atapi import listTypes
43 from Products.PloneXL8.config import PROJECTNAME
44 from Products.PloneXL8.config import product_globals as GLOBALS
45
46 def install(self):
47     """ External Method to install PloneXL8 """
48     out = StringIO()
49     print >> out, "Installation log of %s:" % PROJECTNAME
50
51     # If the config contains a list of dependencies, try to install
52     # them.  Add a list called DEPENDENCIES to your custom
53     # AppConfig.py (imported by config.py) to use it.
54     try:
55         from Products.PloneXL8.config import DEPENDENCIES
56     except:
57         DEPENDENCIES = []
58     portal = getToolByName(self,'portal_url').getPortalObject()
59     quickinstaller = portal.portal_quickinstaller
60     for dependency in DEPENDENCIES:
61         print >> out, "Installing dependency %s:" % dependency
62         quickinstaller.installProduct(dependency)
63         get_transaction().commit(1)
64
65     classes = listTypes(PROJECTNAME)
66     installTypes(self, out,
67                  classes,
68                  PROJECTNAME)
69     install_subskin(self, out, GLOBALS)
70
71
72
73
74     # try to call a workflow install method
75     # in 'InstallWorkflows.py' method 'installWorkflows'
76     try:
77         installWorkflows = ExternalMethod('temp',
78                                           'temp',
79                                           PROJECTNAME+'.InstallWorkflows',
80                                           'installWorkflows').__of__(self)
81     except NotFound:
82         installWorkflows = None
83
84     if installWorkflows:
85         print >>out,'Workflow Install:'
86         res = installWorkflows(self,out)
87         print >>out,res or 'no output'
88     else:
89         print >>out,'no workflow install'
90
91
92     # enable portal_factory for given types
93     factory_tool = getToolByName(self,'portal_factory')
94     factory_types=[
95         "TranslationCenter",
96         "TranslationDoc",
97         ] + factory_tool.getFactoryTypes().keys()
98     factory_tool.manage_setPortalFactoryTypes(listOfTypeIds=factory_types)
99
100     from Products.PloneXL8.config import STYLESHEETS
101     try:
102         portal_css = getToolByName(portal, 'portal_css')
103         for stylesheet in STYLESHEETS:
104             try:
105                 portal_css.unregisterResource(stylesheet['id'])
106             except:
107                 pass
108             defaults = {'id': '',
109             'media': 'all',
110             'enabled': True}
111             defaults.update(stylesheet)
112             portal_css.manage_addStylesheet(**defaults)
113     except:
114         # No portal_css registry
115         pass
116     from Products.PloneXL8.config import JAVASCRIPTS
117     try:
118         portal_javascripts = getToolByName(portal, 'portal_javascripts')
119         for javascript in JAVASCRIPTS:
120             try:
121                 portal_javascripts.unregisterResource(javascript['id'])
122             except:
123                 pass
124             defaults = {'id': ''}
125             defaults.update(javascript)
126             portal_javascripts.registerScript(**defaults)
127     except:
128         # No portal_javascripts registry
129         pass
130
131     # try to call a custom install method
132     # in 'AppInstall.py' method 'install'
133     try:
134         install = ExternalMethod('temp', 'temp',
135                                  PROJECTNAME+'.AppInstall', 'install')
136     except NotFound:
137         install = None
138
139     if install:
140         print >>out,'Custom Install:'
141         res = install(self)
142         if res:
143             print >>out,res
144         else:
145             print >>out,'no output'
146     else:
147         print >>out,'no custom install'
148     return out.getvalue()
149
150 def uninstall(self):
151     out = StringIO()
152
153     # try to call a workflow uninstall method
154     # in 'InstallWorkflows.py' method 'uninstallWorkflows'
155     try:
156         uninstallWorkflows = ExternalMethod('temp', 'temp',
157                                             PROJECTNAME+'.InstallWorkflows',
158                                             'uninstallWorkflows').__of__(self)
159     except NotFound:
160         uninstallWorkflows = None
161
162     if uninstallWorkflows:
163         print >>out, 'Workflow Uninstall:'
164         res = uninstallWorkflows(self, out)
165         print >>out, res or 'no output'
166     else:
167         print >>out,'no workflow uninstall'
168
169     # try to call a custom uninstall method
170     # in 'AppInstall.py' method 'uninstall'
171     try:
172         uninstall = ExternalMethod('temp', 'temp',
173                                    PROJECTNAME+'.AppInstall', 'uninstall')
174     except:
175         uninstall = None
176
177     if uninstall:
178         print >>out,'Custom Uninstall:'
179         res = uninstall(self)
180         if res:
181             print >>out,res
182         else:
183             print >>out,'no output'
184     else:
185         print >>out,'no custom uninstall'
186
187     return out.getvalue()
Note: See TracBrowser for help on using the browser.