source: publico/ILSAALContabilidade/trunk/Extensions/Install.py @ 1318

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

Geração de novo código devido a alterções no modelo

File size: 7.7 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.ILSAALContabilidade.config import PROJECTNAME
44from Products.ILSAALContabilidade.config import product_globals as GLOBALS
45
46def install(self):
47    """ External Method to install ILSAALContabilidade """
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.ILSAALContabilidade.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    # Create vocabularies in vocabulary lib
73    atvm = getToolByName(self, 'portal_vocabularies')
74    vocabmap = {u'cod_situacao': ('SimpleVocabulary', 'SimpleVocabularyTerm'),
75         u'cod_natureza_conta': ('SimpleVocabulary', 'SimpleVocabularyTerm'),
76         u'tip_empenho': ('SimpleVocabulary', 'SimpleVocabularyTerm'),
77         u'cod_status_encerramento': ('SimpleVocabulary', 'SimpleVocabularyTerm'),
78         u'tip_anulacao': ('SimpleVocabulary', 'SimpleVocabularyTerm'),
79         u'tip_modalidade': ('SimpleVocabulary', 'SimpleVocabularyTerm'),
80         u'tip_documento': ('SimpleVocabulary', 'SimpleVocabularyTerm'),
81         u'tip_licitacao': ('SimpleVocabulary', 'SimpleVocabularyTerm'),
82         u'plano_contas': ('SimpleVocabulary', 'SimpleVocabularyTerm'),
83        }
84    for vocabname in vocabmap.keys():
85        if not vocabname in atvm.contentIds():
86            atvm.invokeFactory(vocabmap[vocabname][0], vocabname)
87        if vocabmap[vocabname][0] != "VdexVocabulary" and \
88           len(atvm[vocabname].contentIds()) < 1:
89            atvm[vocabname].invokeFactory(vocabmap[vocabname][1],'default')
90            atvm[vocabname]['default'].setTitle('Default term, replace it by your own stuff')
91
92    # try to call a workflow install method
93    # in 'InstallWorkflows.py' method 'installWorkflows'
94    try:
95        installWorkflows = ExternalMethod('temp','temp',PROJECTNAME+'.InstallWorkflows', 'installWorkflows').__of__(self)
96    except NotFound:
97        installWorkflows = None
98
99    if installWorkflows:
100        print >>out,'Workflow Install:'
101        res = installWorkflows(self,out)
102        print >>out,res or 'no output'
103    else:
104        print >>out,'no workflow install'
105
106
107    # enable portal_factory for given types
108    factory_tool = getToolByName(self,'portal_factory')
109    factory_types=[
110        "AnulacaoEmpenho",
111        "AnulacaoItemEmpenho",
112        "Conta",
113        "RecursoFinanceiro",
114        "Empenho",
115        "ItemEmpenho",
116        "LiquidacaoItemEmpenho",
117        "Liquidacao",
118        "Vinculo",
119        "ControleContabil",
120        "MovimentoContabilidade",
121        "DocumentoFiscal",
122        ] + factory_tool.getFactoryTypes().keys()
123    factory_tool.manage_setPortalFactoryTypes(listOfTypeIds=factory_types)
124
125    # For plone 2.1, allow the easy registering of stylesheets
126    from Products.ILSAALContabilidade.config import HAS_PLONE21
127    if HAS_PLONE21:
128        try:
129            from Products.ILSAALContabilidade.config import STYLESHEETS
130        except:
131            STYLESHEETS = []
132        try:
133            from Products.ILSAALContabilidade.config import JAVASCRIPTS
134        except:
135            JAVASCRIPTS = []
136        portal_css = getToolByName(portal, 'portal_css')
137        portal_javascripts = getToolByName(portal, 'portal_javascripts')
138        for stylesheet in STYLESHEETS:
139            try:
140                portal_css.unregisterResource(stylesheet['id'])
141            except:
142                pass
143            defaulttitle = '%s %s' % (PROJECTNAME, stylesheet['id'])
144            defaults = {'id': '',
145            'expression': None,
146            'media': 'all',
147            'title': defaulttitle,
148            'enabled': True}
149            defaults.update(stylesheet)
150            portal_css.manage_addStylesheet(**defaults)
151        for javascript in JAVASCRIPTS:
152            try:
153                portal_javascripts.unregisterResource(stylesheet['id'])
154            except:
155                pass
156            defaults = {'id': '',
157            'expression': '',
158            'inline': False,
159            'enabled': True,
160            'cookable': True}
161            defaults.update(javascript)
162            portal_javascripts.registerScript(**defaults)
163
164    # try to call a custom install method
165    # in 'AppInstall.py' method 'install'
166    try:
167        install = ExternalMethod('temp','temp',PROJECTNAME+'.AppInstall', 'install')
168    except NotFound:
169        install = None
170
171    if install:
172        print >>out,'Custom Install:'
173        res = install(self)
174        if res:
175            print >>out,res
176        else:
177            print >>out,'no output'
178    else:
179        print >>out,'no custom install'
180    return out.getvalue()
181
182def uninstall(self):
183    out = StringIO()
184
185    # try to call a workflow uninstall method
186    # in 'InstallWorkflows.py' method 'uninstallWorkflows'
187    try:
188        installWorkflows = ExternalMethod('temp','temp',PROJECTNAME+'.InstallWorkflows', 'uninstallWorkflows').__of__(self)
189    except NotFound:
190        installWorkflows = None
191
192    if installWorkflows:
193        print >>out,'Workflow Uninstall:'
194        res = uninstallWorkflows(self,out)
195        print >>out,res or 'no output'
196    else:
197        print >>out,'no workflow uninstall'
198
199    # try to call a custom uninstall method
200    # in 'AppInstall.py' method 'uninstall'
201    try:
202        uninstall = ExternalMethod('temp','temp',PROJECTNAME+'.AppInstall', 'uninstall')
203    except:
204        uninstall = None
205
206    if uninstall:
207        print >>out,'Custom Uninstall:'
208        res = uninstall(self)
209        if res:
210            print >>out,res
211        else:
212            print >>out,'no output'
213    else:
214        print >>out,'no custom uninstall'
215
216    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.