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

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

Codigo gerado do modelo de RH atualizado

File size: 6.5 KB
Linha 
1""" Extensions/Install.py """
2
3# Copyright (c) 2005 by Interlegis
4#
5# Generated:
6# Generator: ArchGenXML Version 1.4.0-beta2 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    # Create vocabularies in vocabulary lib
73    atvm = getToolByName(self, 'portal_vocabularies')
74    vocabmap = {u'codigo_cargo': ('SimpleVocabulary', 'SimpleVocabularyTerm'),
75         u'codigo_nivel': ('SimpleVocabulary', 'SimpleVocabularyTerm'),
76         u'codigo_evento': ('SimpleVocabulary', 'SimpleVocabularyTerm'),
77         u'tipo_dependente': ('SimpleVocabulary', 'SimpleVocabularyTerm'),
78         u'codigo_motivo': ('SimpleVocabulary', 'SimpleVocabularyTerm'),
79         u'cbo': ('SimpleVocabulary', 'SimpleVocabularyTerm'),
80         u'tipo_pensao': ('SimpleVocabulary', 'SimpleVocabularyTerm'),
81         u'tipo_ponto': ('SimpleVocabulary', 'SimpleVocabularyTerm'),
82         u'grau_instrucao': ('SimpleVocabulary', 'SimpleVocabularyTerm'),
83         u'tipo_operacao': ('SimpleVocabulary', 'SimpleVocabularyTerm'),
84         u'raca_cor': ('SimpleVocabulary', 'SimpleVocabularyTerm'),
85         u'codigo_padrao': ('SimpleVocabulary', 'SimpleVocabularyTerm'),
86         u'codigo_vinculo': ('SimpleVocabulary', 'SimpleVocabularyTerm'),
87         u'tipo_admissao': ('SimpleVocabulary', 'SimpleVocabularyTerm'),
88         'PessoaFisica_cod_estado_civil': ('SimpleVocabulary', 'SimpleVocabularyTerm'),
89         u'tipo_documento': ('SimpleVocabulary', 'SimpleVocabularyTerm'),
90        }
91    for vocabname in vocabmap.keys():
92        if not vocabname in atvm.contentIds():
93            atvm.invokeFactory(vocabmap[vocabname][0], vocabname)
94        if vocabmap[vocabname][0] != "VdexVocabulary" and \
95           len(atvm[vocabname].contentIds()) < 1:
96            atvm[vocabname].invokeFactory(vocabmap[vocabname][1],'default')
97            atvm[vocabname]['default'].setTitle('Default term, replace it by your own stuff')
98
99    # try to call a workflow install method
100    # in 'InstallWorkflows.py' method 'installWorkflows'
101    try:
102        installWorkflows = ExternalMethod('temp','temp',PROJECTNAME+'.InstallWorkflows', 'installWorkflows').__of__(self)
103    except NotFound:
104        installWorkflows = None
105
106    if installWorkflows:
107        print >>out,'Workflow Install:'
108        res = installWorkflows(self,out)
109        print >>out,res or 'no output'
110    else:
111        print >>out,'no workflow install'
112
113
114    # enable portal_factory for given types
115    factory_tool = getToolByName(self,'portal_factory')
116    factory_types=[
117        ] + factory_tool.getFactoryTypes().keys()
118    factory_tool.manage_setPortalFactoryTypes(listOfTypeIds=factory_types)
119
120    # try to call a custom install method
121    # in 'AppInstall.py' method 'install'
122    try:
123        install = ExternalMethod('temp','temp',PROJECTNAME+'.AppInstall', 'install')
124    except NotFound:
125        install = None
126
127    if install:
128        print >>out,'Custom Install:'
129        res = install(self)
130        if res:
131            print >>out,res
132        else:
133            print >>out,'no output'
134    else:
135        print >>out,'no custom install'
136    return out.getvalue()
137
138def uninstall(self):
139    out = StringIO()
140
141    # try to call a workflow uninstall method
142    # in 'InstallWorkflows.py' method 'uninstallWorkflows'
143    try:
144        installWorkflows = ExternalMethod('temp','temp',PROJECTNAME+'.InstallWorkflows', 'uninstallWorkflows').__of__(self)
145    except NotFound:
146        installWorkflows = None
147
148    if installWorkflows:
149        print >>out,'Workflow Uninstall:'
150        res = uninstallWorkflows(self,out)
151        print >>out,res or 'no output'
152    else:
153        print >>out,'no workflow uninstall'
154
155    # try to call a custom uninstall method
156    # in 'AppInstall.py' method 'uninstall'
157    try:
158        uninstall = ExternalMethod('temp','temp',PROJECTNAME+'.AppInstall', 'uninstall')
159    except:
160        uninstall = None
161
162    if uninstall:
163        print >>out,'Custom Uninstall:'
164        res = uninstall(self)
165        if res:
166            print >>out,res
167        else:
168            print >>out,'no output'
169    else:
170        print >>out,'no custom uninstall'
171
172    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.