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

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

correção na busca de conteudo das casas

File size: 6.2 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    #bind classes to workflows
91    wft = getToolByName(self,'portal_workflow')
92    wft.setChainForPortalTypes( ['Resposta'], '')
93
94    # enable portal_factory for given types
95    factory_tool = getToolByName(self,'portal_factory')
96    factory_types=[
97        "MelhoresPraticas",
98        "VideoConferencia",
99        "TextoPasta",
100        "SolicitacaoFolder",
101        "Solicitacao",
102        "Resposta",
103        ] + factory_tool.getFactoryTypes().keys()
104    factory_tool.manage_setPortalFactoryTypes(listOfTypeIds=factory_types)
105
106    from Products.ILPortal.config import STYLESHEETS
107    try:
108        portal_css = getToolByName(portal, 'portal_css')
109        for stylesheet in STYLESHEETS:
110            try:
111                portal_css.unregisterResource(stylesheet['id'])
112            except:
113                pass
114            defaults = {'id': '',
115            'media': 'all',
116            'enabled': True}
117            defaults.update(stylesheet)
118            portal_css.manage_addStylesheet(**defaults)
119    except:
120        # No portal_css registry
121        pass
122    from Products.ILPortal.config import JAVASCRIPTS
123    try:
124        portal_javascripts = getToolByName(portal, 'portal_javascripts')
125        for javascript in JAVASCRIPTS:
126            try:
127                portal_javascripts.unregisterResource(javascript['id'])
128            except:
129                pass
130            defaults = {'id': ''}
131            defaults.update(javascript)
132            portal_javascripts.registerScript(**defaults)
133    except:
134        # No portal_javascripts registry
135        pass
136
137    # try to call a custom install method
138    # in 'AppInstall.py' method 'install'
139    try:
140        install = ExternalMethod('temp', 'temp',
141                                 PROJECTNAME+'.AppInstall', 'install')
142    except NotFound:
143        install = None
144
145    if install:
146        print >>out,'Custom Install:'
147        res = install(self)
148        if res:
149            print >>out,res
150        else:
151            print >>out,'no output'
152    else:
153        print >>out,'no custom install'
154    return out.getvalue()
155
156def uninstall(self):
157    out = StringIO()
158
159    # try to call a workflow uninstall method
160    # in 'InstallWorkflows.py' method 'uninstallWorkflows'
161    try:
162        uninstallWorkflows = ExternalMethod('temp', 'temp',
163                                            PROJECTNAME+'.InstallWorkflows',
164                                            'uninstallWorkflows').__of__(self)
165    except NotFound:
166        uninstallWorkflows = None
167
168    if uninstallWorkflows:
169        print >>out, 'Workflow Uninstall:'
170        res = uninstallWorkflows(self, out)
171        print >>out, res or 'no output'
172    else:
173        print >>out,'no workflow uninstall'
174
175    # try to call a custom uninstall method
176    # in 'AppInstall.py' method 'uninstall'
177    try:
178        uninstall = ExternalMethod('temp', 'temp',
179                                   PROJECTNAME+'.AppInstall', 'uninstall')
180    except:
181        uninstall = None
182
183    if uninstall:
184        print >>out,'Custom Uninstall:'
185        res = uninstall(self)
186        if res:
187            print >>out,res
188        else:
189            print >>out,'no output'
190    else:
191        print >>out,'no custom uninstall'
192
193    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.