source: publico/ILSAALRecursosHumanos/trunk/Extensions/Install.py @ 1131

Última Alteração nesse arquivo desde 1131 foi 1131, incluída por jonesmadruga, 14 anos atrás

codigo gerado a partir do novo modelo

File size: 6.2 KB
Linha 
1""" Extensions/Install.py """
2
3# Copyright (c) 2005 by Interlegis
4#
5# Generated:
6# Generator: ArchGenXML Version 1.4.0-RC1 devel
7#            http://plone.org/products/archgenxml
8#
9# GNU General Public Licence (GPL)
10#
11# This program is free software; you can redistribute it and/or modify it under
12# the terms of the GNU General Public License as published by the Free Software
13# Foundation; either version 2 of the License, or (at your option) any later
14# version.
15# This program is distributed in the hope that it will be useful, but WITHOUT
16# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
18# details.
19# You should have received a copy of the GNU General Public License along with
20# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21# Place, Suite 330, Boston, MA  02111-1307  USA
22#
23__author__    = '''STC Interlegis <stc@interlegis.gov.br>'''
24__docformat__ = 'plaintext'
25__version__   = '$ Revision 0.0 $'[11:-2]
26
27import os.path
28import sys
29from StringIO import StringIO
30
31from App.Common import package_home
32from Products.CMFCore.utils import getToolByName
33from Products.CMFCore.utils import manage_addTool
34from Products.ExternalMethod.ExternalMethod import ExternalMethod
35from zExceptions import NotFound, BadRequest
36
37from Products.Archetypes.Extensions.utils import installTypes
38from Products.Archetypes.Extensions.utils import install_subskin
39try:
40    from Products.Archetypes.lib.register import listTypes
41except ImportError:
42    from Products.Archetypes.public import listTypes
43from Products.ILSAALRecursosHumanos.config import PROJECTNAME
44from Products.ILSAALRecursosHumanos.config import product_globals as GLOBALS
45
46def install(self):
47    """ External Method to install ILSAALRecursosHumanos """
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.ILSAALRecursosHumanos.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    # try to call a workflow install method
73    # in 'InstallWorkflows.py' method 'installWorkflows'
74    try:
75        installWorkflows = ExternalMethod('temp','temp',PROJECTNAME+'.InstallWorkflows', 'installWorkflows').__of__(self)
76    except NotFound:
77        installWorkflows = None
78
79    if installWorkflows:
80        print >>out,'Workflow Install:'
81        res = installWorkflows(self,out)
82        print >>out,res or 'no output'
83    else:
84        print >>out,'no workflow install'
85
86
87    # enable portal_factory for given types
88    factory_tool = getToolByName(self,'portal_factory')
89    factory_types=[
90        ] + factory_tool.getFactoryTypes().keys()
91    factory_tool.manage_setPortalFactoryTypes(listOfTypeIds=factory_types)
92
93    # For plone 2.1, allow the easy registering of stylesheets
94    from Products.ILSAALRecursosHumanos.config import HAS_PLONE21
95    if HAS_PLONE21:
96        try:
97            from Products.ILSAALRecursosHumanos.config import STYLESHEETS
98        except:
99            STYLESHEETS = []
100        try:
101            from Products.ILSAALRecursosHumanos.config import JAVASCRIPTS
102        except:
103            JAVASCRIPTS = []
104        portal_css = getToolByName(portal, 'portal_css')
105        portal_javascripts = getToolByName(portal, 'portal_javascripts')
106        for stylesheet in STYLESHEETS:
107            try:
108                portal_css.unregisterResource(stylesheet['id'])
109            except:
110                pass
111            defaulttitle = '%s %s' % (PROJECTNAME, stylesheet['id'])
112            defaults = {'id': '',
113            'expression': None,
114            'media': 'all',
115            'title': defaulttitle,
116            'enabled': True}
117            defaults.update(stylesheet)
118            portal_css.manage_addStylesheet(**defaults)
119        for javascript in JAVASCRIPTS:
120            try:
121                portal_javascripts.unregisterResource(stylesheet['id'])
122            except:
123                pass
124            defaults = {'id': '',
125            'expression': '',
126            'inline': False,
127            'enabled': True,
128            'cookable': True}
129            defaults.update(javascript)
130            portal_javascripts.registerScript(**defaults)
131
132    # try to call a custom install method
133    # in 'AppInstall.py' method 'install'
134    try:
135        install = ExternalMethod('temp','temp',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        installWorkflows = ExternalMethod('temp','temp',PROJECTNAME+'.InstallWorkflows', 'uninstallWorkflows').__of__(self)
157    except NotFound:
158        installWorkflows = None
159
160    if installWorkflows:
161        print >>out,'Workflow Uninstall:'
162        res = uninstallWorkflows(self,out)
163        print >>out,res or 'no output'
164    else:
165        print >>out,'no workflow uninstall'
166
167    # try to call a custom uninstall method
168    # in 'AppInstall.py' method 'uninstall'
169    try:
170        uninstall = ExternalMethod('temp','temp',PROJECTNAME+'.AppInstall', 'uninstall')
171    except:
172        uninstall = None
173
174    if uninstall:
175        print >>out,'Custom Uninstall:'
176        res = uninstall(self)
177        if res:
178            print >>out,res
179        else:
180            print >>out,'no output'
181    else:
182        print >>out,'no custom uninstall'
183
184    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.