Conjunto de mudanças 6528 no repositório publico


Ignorar:
Timestamp:
18/06/2012 19:46:42 (9 anos atrás)
Autor:
jeanferri
Mensagem:

Adicionando modificações feitas após a regeração do código com o ArchGenXML 1.5.3 nos scripts de instalação e workflows da ouvidoria

Localização:
Ombudsman/trunk/Extensions
Arquivos:
5 editados

Legenda:

Não Modificado
Adicionado
Removido
  • Ombudsman/trunk/Extensions/Install.py

    r6423 r6528  
     1# -*- coding: utf-8 -*-
     2#
    13# File: Install.py
    24#
    3 # Copyright (c) 2006 by Rafahela Garcia Bazzanella
    4 # Generator: ArchGenXML Version 1.5.0 svn/devel
     5# Copyright (c) 2012 by Interlegis
     6# Generator: ArchGenXML Version 1.5.3 dev/svn
    57#            http://plone.org/products/archgenxml
    68#
     
    2325#
    2426
    25 __author__ = """Rafahela Bazzanella <rafabazzanella@yahoo.com.br>, Jean Rodrigo Ferri
    26 <jeanrodrigoferri@yahoo.com.br>"""
     27__author__ = """Rafahela Garcia Bazzanella <rafahela@gmail.com>, Jean Rodrigo Ferri
     28<jeanferri@gmail.com>"""
    2729__docformat__ = 'plaintext'
    2830
     
    4547from Products.Ombudsman.config import product_globals as GLOBALS
    4648
    47 def install(self):
     49def install(self, reinstall=False):
    4850    """ External Method to install Ombudsman """
    4951    out = StringIO()
     
    7072    install_subskin(self, out, GLOBALS)
    7173
    72     #autoinstall tools
     74    # autoinstall tools
    7375    portal = getToolByName(self,'portal_url').getPortalObject()
    7476    for t in ['OmbudsmanTool']:
     
    8385            if e[0] != 'Bad Request':
    8486                raise
    85     #hide tools in the navigation
     87
     88    # hide tools in the search form
     89    portalProperties = getToolByName(self, 'portal_properties', None)
     90    if portalProperties is not None:
     91        siteProperties = getattr(portalProperties, 'site_properties', None)
     92        if siteProperties is not None and siteProperties.hasProperty('types_not_searched'):
     93            for tool in ['OmbudsmanTool']:
     94                current = list(siteProperties.getProperty('types_not_searched'))
     95                if tool not in current:
     96                    current.append(tool)
     97                    siteProperties.manage_changeProperties(**{'types_not_searched' : current})
     98
     99    # remove workflow for tools
     100    portal_workflow = getToolByName(self, 'portal_workflow')
     101    for tool in ['OmbudsmanTool']:
     102        portal_workflow.setChainForPortalTypes([tool], '')
     103
     104    # uncatalog tools
     105    for toolname in ['portal_ombudsman']:
     106        try:
     107            portal[toolname].unindexObject()
     108        except:
     109            pass
     110
     111    # hide tools in the navigation
    86112    portalProperties = getToolByName(self, 'portal_properties', None)
    87113    if portalProperties is not None:
    88114        navtreeProperties = getattr(portalProperties, 'navtree_properties', None)
    89         if navtreeProperties:
    90             navtreeProperties.idsNotToList = list(navtreeProperties.idsNotToList) + \
    91                                   [toolname for toolname in ['portal_ombudsman'] \
    92                                             if toolname not in navtreeProperties.idsNotToList]
     115        if navtreeProperties is not None and navtreeProperties.hasProperty('idsNotToList'):
     116            for toolname in ['portal_ombudsman']:
     117                current = list(navtreeProperties.getProperty('idsNotToList'))
     118                if toolname not in current:
     119                    current.append(toolname)
     120                    navtreeProperties.manage_changeProperties(**{'idsNotToList' : current})
     121
    93122    # register tools as configlets
    94123    portal_controlpanel = getToolByName(self,'portal_controlpanel')
     
    96125    portal_controlpanel.registerConfiglet(
    97126        'OmbudsmanTool', #id of your Tool
    98         'Ombudsman Tool', # Title of your Troduct
    99         'string:${portal_url}/portal_ombudsman//',
    100         '''python:True''', # a condition
    101         'Manage Portal', # access permission
     127        'Ombudsman Tool', # Title of your Product
     128        'string:${portal_url}/portal_ombudsman/view',
     129        'python:True', # a condition
     130        'Manage portal', # access permission
    102131        'Products', # section to which the configlet should be added: (Plone, Products (default) or Member)
    103132        1, # visibility
     
    130159    wft.setChainForPortalTypes( ['OmbudsmanResponse'], '')
    131160
     161    # update workflow for created tools if they have been designated a workflow
     162    for toolname in ['portal_ombudsman']:
     163        try:
     164            portal[toolname].notifyWorkflowCreated()
     165        except:
     166            pass
     167
    132168    # enable portal_factory for given types
    133169    factory_tool = getToolByName(self,'portal_factory')
    134170    factory_types=[
     171        "OmbudsmanTool",
    135172        "Ombudsman",
    136173        "OmbudsmanClaim",
     
    151188            'enabled': True}
    152189            defaults.update(stylesheet)
    153             portal_css.manage_addStylesheet(**defaults)
     190            portal_css.registerStylesheet(**defaults)
    154191    except:
    155192        # No portal_css registry
     
    180217    if install:
    181218        print >>out,'Custom Install:'
    182         res = install(self)
     219        try:
     220            res = install(self, reinstall)
     221        except TypeError:
     222            res = install(self)
    183223        if res:
    184224            print >>out,res
     
    189229    return out.getvalue()
    190230
    191 def uninstall(self):
     231def uninstall(self, reinstall=False):
    192232    out = StringIO()
     233
     234
     235    # unhide tools in the search form
     236    portalProperties = getToolByName(self, 'portal_properties', None)
     237    if portalProperties is not None:
     238        siteProperties = getattr(portalProperties, 'site_properties', None)
     239        if siteProperties is not None and siteProperties.hasProperty('types_not_searched'):
     240            for tool in ['OmbudsmanTool']:
     241                current = list(siteProperties.getProperty('types_not_searched'))
     242                if tool in current:
     243                    current.remove(tool)
     244                    siteProperties.manage_changeProperties(**{'types_not_searched' : current})
     245
    193246
    194247    # unhide tools
     
    196249    if portalProperties is not None:
    197250        navtreeProperties = getattr(portalProperties, 'navtree_properties', None)
    198         if navtreeProperties:
    199             navtreeProperties.idsNotToList = list(navtreeProperties.idsNotToList)
    200             for toolname in [toolname for toolname in ['portal_ombudsman'] \
    201                                       if toolname not in navtreeProperties.idsNotToList]:
    202                 if toolname in navtreeProperties.idsNotToList:
    203                     navtreeProperties.idsNotToList.remove(toolname)
     251        if navtreeProperties is not None and navtreeProperties.hasProperty('idsNotToList'):
     252            for toolname in ['portal_ombudsman']:
     253                current = list(navtreeProperties.getProperty('idsNotToList'))
     254                if toolname in current:
     255                    current.remove(toolname)
     256                    navtreeProperties.manage_changeProperties(**{'idsNotToList' : current})
    204257
    205258
     
    234287    if uninstall:
    235288        print >>out,'Custom Uninstall:'
    236         res = uninstall(self)
     289        try:
     290            res = uninstall(self, reinstall)
     291        except TypeError:
     292            res = uninstall(self)
    237293        if res:
    238294            print >>out,res
     
    243299
    244300    return out.getvalue()
     301
     302def beforeUninstall(self, reinstall, product, cascade):
     303    """ try to call a custom beforeUninstall method in 'AppInstall.py'
     304        method 'beforeUninstall'
     305    """
     306    out = StringIO()
     307    try:
     308        beforeuninstall = ExternalMethod('temp', 'temp',
     309                                   PROJECTNAME+'.AppInstall', 'beforeUninstall')
     310    except:
     311        beforeuninstall = []
     312
     313    if beforeuninstall:
     314        print >>out, 'Custom beforeUninstall:'
     315        res = beforeuninstall(self, reinstall=reinstall
     316                                  , product=product
     317                                  , cascade=cascade)
     318        if res:
     319            print >>out, res
     320        else:
     321            print >>out, 'no output'
     322    else:
     323        print >>out, 'no custom beforeUninstall'
     324    return (out,cascade)
     325
     326def afterInstall(self, reinstall, product):
     327    """ try to call a custom afterInstall method in 'AppInstall.py' method
     328        'afterInstall'
     329    """
     330    out = StringIO()
     331    try:
     332        afterinstall = ExternalMethod('temp', 'temp',
     333                                   PROJECTNAME+'.AppInstall', 'afterInstall')
     334    except:
     335        afterinstall = None
     336
     337    if afterinstall:
     338        print >>out, 'Custom afterInstall:'
     339        res = afterinstall(self, product=None
     340                               , reinstall=None)
     341        if res:
     342            print >>out, res
     343        else:
     344            print >>out, 'no output'
     345    else:
     346        print >>out, 'no custom afterInstall'
     347    return out
  • Ombudsman/trunk/Extensions/InstallWorkflows.py

    r6423 r6528  
     1# -*- coding: utf-8 -*-
     2#
    13# File: Ombudsman.py
    24#
    3 # Copyright (c) 2006 by Rafahela Garcia Bazzanella
    4 # Generator: ArchGenXML Version 1.5.0 svn/devel
     5# Copyright (c) 2012 by Interlegis
     6# Generator: ArchGenXML Version 1.5.3 dev/svn
    57#            http://plone.org/products/archgenxml
    68#
     
    2325#
    2426
    25 __author__ = """Rafahela Bazzanella <rafabazzanella@yahoo.com.br>, Jean Rodrigo Ferri
    26 <jeanrodrigoferri@yahoo.com.br>"""
     27__author__ = """Rafahela Garcia Bazzanella <rafahela@gmail.com>, Jean Rodrigo Ferri
     28<jeanferri@gmail.com>"""
    2729__docformat__ = 'plaintext'
    2830
     
    4143
    4244    ourProductWorkflow = ExternalMethod('temp', 'temp',
    43                          productname+'.'+'ombudsman_workflow',
    44                          'createombudsman_workflow')
     45                                        productname+'.'+'ombudsman_workflow',
     46                                        'createombudsman_workflow')
    4547    workflow = ourProductWorkflow(self, 'ombudsman_workflow')
    46     workflowTool._setObject('ombudsman_workflow', workflow)
     48    if workflow.getId() in workflowTool.listWorkflows():
     49        print >> out, '%s already in workflows.' % workflow.getId()
     50    else:
     51        try:
     52            # plone 2.x
     53            workflowTool._setObject('ombudsman_workflow', workflow)
     54        except:
     55            # works in Plone 3.0, but isnt perfect! use ArchGenXML 2.0 for a
     56            # better result!
     57            workflowTool._setOb('ombudsman_workflow', workflow)
     58        print >> out, '%s added in workflows.' % workflow.getId()
    4759    workflowTool.setChainForPortalTypes(['Ombudsman'], workflow.getId())
    4860
    4961    ourProductWorkflow = ExternalMethod('temp', 'temp',
    50                          productname+'.'+'ombudsman_claim_workflow',
    51                          'createombudsman_claim_workflow')
     62                                        productname+'.'+'ombudsman_claim_workflow',
     63                                        'createombudsman_claim_workflow')
    5264    workflow = ourProductWorkflow(self, 'ombudsman_claim_workflow')
    53     workflowTool._setObject('ombudsman_claim_workflow', workflow)
     65    if workflow.getId() in workflowTool.listWorkflows():
     66        print >> out, '%s already in workflows.' % workflow.getId()
     67    else:
     68        try:
     69            # plone 2.x
     70            workflowTool._setObject('ombudsman_claim_workflow', workflow)
     71        except:
     72            # works in Plone 3.0, but isnt perfect! use ArchGenXML 2.0 for a
     73            # better result!
     74            workflowTool._setOb('ombudsman_claim_workflow', workflow)
     75        print >> out, '%s added in workflows.' % workflow.getId()
    5476    workflowTool.setChainForPortalTypes(['OmbudsmanClaim'], workflow.getId())
    5577
     
    5779    ##/code-section after-workflow-install
    5880
    59     return workflowTool
     81    return out
    6082
    6183def uninstallWorkflows(self, package, out):
     
    6587    code here in the protected section.
    6688    """
     89    workflowTool = getToolByName(self, 'portal_workflow')
     90    workflowTool.manage_delObjects(['ombudsman_workflow'])
     91    workflowTool.manage_delObjects(['ombudsman_claim_workflow'])
    6792
    6893    ##code-section workflow-uninstall #fill in your manual code here
  • Ombudsman/trunk/Extensions/ombudsman_claim_workflow.py

    r6423 r6528  
     1# -*- coding: utf-8 -*-
     2#
    13# File: Ombudsman.py
    24#
    3 # Copyright (c) 2006 by Rafahela Garcia Bazzanella
    4 # Generator: ArchGenXML Version 1.5.0 svn/devel
     5# Copyright (c) 2012 by Interlegis
     6# Generator: ArchGenXML Version 1.5.3 dev/svn
    57#            http://plone.org/products/archgenxml
    68#
     
    2325#
    2426
    25 __author__ = """Rafahela Bazzanella <rafabazzanella@yahoo.com.br>, Jean Rodrigo Ferri
    26 <jeanrodrigoferri@yahoo.com.br>"""
     27__author__ = """Rafahela Garcia Bazzanella <rafahela@gmail.com>, Jean Rodrigo Ferri
     28<jeanferri@gmail.com>"""
    2729__docformat__ = 'plaintext'
    2830
    2931
    3032from Products.CMFCore.utils import getToolByName
    31 from Products.CMFCore.WorkflowTool import addWorkflowFactory
    3233from Products.DCWorkflow.DCWorkflow import DCWorkflowDefinition
    3334from Products.ExternalMethod.ExternalMethod import ExternalMethod
     
    7576    stateDef = workflow.states['pending']
    7677    stateDef.setProperties(title="""Pending""",
     78                           description="""""",
    7779                           transitions=['reject', 'accept', 'move'])
    7880    stateDef.setPermission('Modify portal content',
     
    8890    stateDef = workflow.states['accepted']
    8991    stateDef.setProperties(title="""Accepted""",
     92                           description="""""",
    9093                           transitions=['move', 'resolve'])
    9194    stateDef.setPermission('Modify portal content',
     
    101104    stateDef = workflow.states['rejected']
    102105    stateDef.setProperties(title="""Rejected""",
     106                           description="""""",
    103107                           transitions=[])
    104108    stateDef.setPermission('Modify portal content',
     
    114118    stateDef = workflow.states['resolved']
    115119    stateDef.setProperties(title="""Resolved""",
     120                           description="""""",
    116121                           transitions=[])
    117122    stateDef.setPermission('Modify portal content',
     
    127132    stateDef = workflow.states['moving']
    128133    stateDef.setProperties(title="""Moving""",
     134                           description="""""",
    129135                           transitions=['resolve', 'move'])
    130136    stateDef.setPermission('Modify portal content',
     
    140146    stateDef = workflow.states['new']
    141147    stateDef.setProperties(title="""Being created""",
     148                           description="""""",
    142149                           transitions=['post'])
    143150    stateDef.setPermission('Modify portal content',
     
    307314    return ob
    308315
    309 addWorkflowFactory(createombudsman_claim_workflow,
    310                    id='ombudsman_claim_workflow',
    311                    title='ombudsman_claim_workflow')
     316#addWorkflowFactory(createombudsman_claim_workflow,
     317#                   id='ombudsman_claim_workflow',
     318#                   title='ombudsman_claim_workflow')
    312319
    313320##code-section create-workflow-module-footer #fill in your manual code here
  • Ombudsman/trunk/Extensions/ombudsman_claim_workflow_scripts.py

    r6423 r6528  
     1# -*- coding: utf-8 -*-
     2#
    13# File: Ombudsman.py
    24#
    3 # Copyright (c) 2006 by Rafahela Garcia Bazzanella
    4 # Generator: ArchGenXML Version 1.5.0 svn/devel
     5# Copyright (c) 2012 by Interlegis
     6# Generator: ArchGenXML Version 1.5.3 dev/svn
    57#            http://plone.org/products/archgenxml
    68#
     
    2325#
    2426
    25 __author__ = """Rafahela Bazzanella <rafabazzanella@yahoo.com.br>, Jean Rodrigo Ferri
    26 <jeanrodrigoferri@yahoo.com.br>"""
     27__author__ = """Rafahela Garcia Bazzanella <rafahela@gmail.com>, Jean Rodrigo Ferri
     28<jeanferri@gmail.com>"""
    2729__docformat__ = 'plaintext'
    2830
  • Ombudsman/trunk/Extensions/ombudsman_workflow.py

    r6423 r6528  
     1# -*- coding: utf-8 -*-
     2#
    13# File: Ombudsman.py
    24#
    3 # Copyright (c) 2006 by Rafahela Garcia Bazzanella
    4 # Generator: ArchGenXML Version 1.5.0 svn/devel
     5# Copyright (c) 2012 by Interlegis
     6# Generator: ArchGenXML Version 1.5.3 dev/svn
    57#            http://plone.org/products/archgenxml
    68#
     
    2325#
    2426
    25 __author__ = """Rafahela Bazzanella <rafabazzanella@yahoo.com.br>, Jean Rodrigo Ferri
    26 <jeanrodrigoferri@yahoo.com.br>"""
     27__author__ = """Rafahela Garcia Bazzanella <rafahela@gmail.com>, Jean Rodrigo Ferri
     28<jeanferri@gmail.com>"""
    2729__docformat__ = 'plaintext'
    2830
    2931
    3032from Products.CMFCore.utils import getToolByName
    31 from Products.CMFCore.WorkflowTool import addWorkflowFactory
    3233from Products.DCWorkflow.DCWorkflow import DCWorkflowDefinition
    3334from Products.ExternalMethod.ExternalMethod import ExternalMethod
     
    4950        if not role in data:
    5051            data.append(role)
     52            # add to portal_role_manager
     53            # first try to fetch it. if its not there, we probaly have no PAS
     54            # or another way to deal with roles was configured.           
     55            try:
     56                prm = portal.acl_users.get('portal_role_manager', None)
     57                if prm is not None:
     58                    try:
     59                        prm.addRole(role, role,
     60                                    "Added by product 'Ombudsman'/workflow 'ombudsman_workflow'")
     61                    except KeyError: # role already exists
     62                        pass
     63            except AttributeError:
     64                pass
    5165    portal.__ac_roles__ = tuple(data)
    5266
     
    86100    stateDef = workflow.states['published']
    87101    stateDef.setProperties(title="""Published""",
     102                           description="""""",
    88103                           transitions=['publish_post', 'publish_view', 'authenticate', 'authenticate_post', 'authenticate_view'])
    89104    stateDef.setPermission('View',
     
    111126    stateDef = workflow.states['authenticated']
    112127    stateDef.setProperties(title="""Authenticated""",
     128                           description="""""",
    113129                           transitions=['authenticate_post', 'authenticate_view', 'publish'])
    114130    stateDef.setPermission('View',
     
    136152    stateDef = workflow.states['published_post']
    137153    stateDef.setProperties(title="""Published Post""",
     154                           description="""""",
    138155                           transitions=['publish'])
    139156    stateDef.setPermission('View',
     
    161178    stateDef = workflow.states['published_view']
    162179    stateDef.setProperties(title="""Published View""",
     180                           description="""""",
    163181                           transitions=['publish'])
    164182    stateDef.setPermission('View',
     
    186204    stateDef = workflow.states['autheticated_post']
    187205    stateDef.setProperties(title="""Authenticated Post""",
     206                           description="""""",
    188207                           transitions=['authenticate'])
    189208    stateDef.setPermission('View',
     
    211230    stateDef = workflow.states['authenticated_view']
    212231    stateDef.setProperties(title="""Authenticated View""",
     232                           description="""""",
    213233                           transitions=['authenticate'])
    214234    stateDef.setPermission('View',
     
    376396    return ob
    377397
    378 addWorkflowFactory(createombudsman_workflow,
    379                    id='ombudsman_workflow',
    380                    title='ombudsman_workflow')
     398#addWorkflowFactory(createombudsman_workflow,
     399#                   id='ombudsman_workflow',
     400#                   title='ombudsman_workflow')
    381401
    382402##code-section create-workflow-module-footer #fill in your manual code here
Note: Veja TracChangeset para ajuda no uso do visualizador de conjunto de mudanças.
 

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