source: publico/ILPortal/trunk/Extensions/Install.py @ 2548

Última Alteração nesse arquivo desde 2548 foi 2548, incluída por paulovieira, 13 anos atrás

undo da última modificação

File size: 6.0 KB
Linha 
1# -*- coding: utf-8 -*-
2#
3# File: Install.py
4#
5# Copyright (c) 2006 by Interlegis
6# Generator: ArchGenXML Version 1.5.0 svn/devel
7#            http://plone.org/products/archgenxml
8#
9# GNU General Public License (GPL)
10#
11# This program is free software; you can redistribute it and/or
12# modify it under the terms of the GNU General Public License
13# as published by the Free Software Foundation; either version 2
14# of the License, or (at your option) any later version.
15#
16# This program is distributed in the hope that it will be useful,
17# but WITHOUT ANY WARRANTY; without even the implied warranty of
18# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19# GNU General Public License for more details.
20#
21# You should have received a copy of the GNU General Public License
22# along with this program; if not, write to the Free Software
23# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24# 02110-1301, USA.
25#
26
27__author__ = """STC Interlegis <admin-stc@interlegis.gov.br>"""
28__docformat__ = 'plaintext'
29
30
31import os.path
32import sys
33from StringIO import StringIO
34from sets import Set
35from App.Common import package_home
36from Products.CMFCore.utils import getToolByName
37from Products.CMFCore.utils import manage_addTool
38from Products.ExternalMethod.ExternalMethod import ExternalMethod
39from zExceptions import NotFound, BadRequest
40
41from Products.Archetypes.Extensions.utils import installTypes
42from Products.Archetypes.Extensions.utils import install_subskin
43from Products.Archetypes.config import TOOL_NAME as ARCHETYPETOOLNAME
44from Products.Archetypes.atapi import listTypes
45from Products.ILPortal.config import PROJECTNAME
46from Products.ILPortal.config import product_globals as GLOBALS
47
48def install(self):
49    """ External Method to install ILPortal """
50    out = StringIO()
51    print >> out, "Installation log of %s:" % PROJECTNAME
52
53    # If the config contains a list of dependencies, try to install
54    # them.  Add a list called DEPENDENCIES to your custom
55    # AppConfig.py (imported by config.py) to use it.
56    try:
57        from Products.ILPortal.config import DEPENDENCIES
58    except:
59        DEPENDENCIES = []
60    portal = getToolByName(self,'portal_url').getPortalObject()
61    quickinstaller = portal.portal_quickinstaller
62    for dependency in DEPENDENCIES:
63        print >> out, "Installing dependency %s:" % dependency
64        quickinstaller.installProduct(dependency)
65        get_transaction().commit(1)
66
67    classes = listTypes(PROJECTNAME)
68    installTypes(self, out,
69                 classes,
70                 PROJECTNAME)
71    install_subskin(self, out, GLOBALS)
72
73
74    # try to call a workflow install method
75    # in 'InstallWorkflows.py' method 'installWorkflows'
76    try:
77        installWorkflows = ExternalMethod('temp', 'temp',
78                                          PROJECTNAME+'.InstallWorkflows',
79                                          'installWorkflows').__of__(self)
80    except NotFound:
81        installWorkflows = None
82
83    if installWorkflows:
84        print >>out,'Workflow Install:'
85        res = installWorkflows(self,out)
86        print >>out,res or 'no output'
87    else:
88        print >>out,'no workflow install'
89
90
91    # enable portal_factory for given types
92    factory_tool = getToolByName(self,'portal_factory')
93    factory_types=[
94        "MelhoresPraticas",
95        "VideoConferencia",
96        "TextoPasta",
97        ] + factory_tool.getFactoryTypes().keys()
98    factory_tool.manage_setPortalFactoryTypes(listOfTypeIds=factory_types)
99
100    from Products.ILPortal.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.ILPortal.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
150def 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: Veja TracBrowser para ajuda no uso do navegador do trac.
 

The contents and data of this website are published under license:
Creative Commons 4.0 Brasil - Atribuir Fonte - Compartilhar Igual.