Skip to content

Commit

Permalink
Merge pull request #18 from eea/develop
Browse files Browse the repository at this point in the history
Move workflow.progress.xml generic profile export / import to eea.progress.workflow
  • Loading branch information
avoinea authored Mar 11, 2022
2 parents 99cbe55 + 59f85c8 commit 291e3f7
Show file tree
Hide file tree
Showing 9 changed files with 7 additions and 340 deletions.
5 changes: 5 additions & 0 deletions docs/HISTORY.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Changelog
=========

6.0 - (2022-03-11)
---------------------------
* Change: Move workflow.progress.xml generic profile export / import to eea.progress.workflow
[avoinea refs #145772]

5.1 - (2021-06-14)
---------------------------
* Feature: read fields and behaviors from dexterity content
Expand Down
4 changes: 0 additions & 4 deletions eea/progressbar/api/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
xmlns:zcml="http://namespaces.zope.org/zcml"
i18n_domain="eea">

<class class="Products.CMFPlone.WorkflowTool.WorkflowTool">
<implements interface="eea.progressbar.interfaces.IWorkflowTool" />
</class>

<class class="plone.app.collection.collection.Collection">
<implements interface="eea.progressbar.interfaces.ICollection" />
</class>
Expand Down
124 changes: 0 additions & 124 deletions eea/progressbar/docs/exportimport.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,131 +11,7 @@ XML Adapters to be used within GenericSetup profiles
>>> from Products.GenericSetup.testing import DummySetupEnviron
>>> from Products.CMFCore.utils import getToolByName
>>> from eea.progressbar.interfaces import IProgressBarLayer

Workflow Exporter / Importer
============================

::

>>> portal = layer['portal']
>>> wftool = getToolByName(portal, 'portal_workflow')
>>> exporter = importer = queryMultiAdapter((wftool, DummySetupEnviron()),
... IBody, name=u'workflows.progress.xml')
>>> exporter
<eea.progressbar.exportimport.progress.WorkflowToolXMLAdapter object at ...>


By default there is no progress defined for workflow states

::

>>> print exporter.body
<?xml version="1.0"?>
...
<object name="one_state_workflow" meta_type="Workflow">
<object name="published" meta_type="Workflow State"/>
</object>
...

Let's set some progress

::

>>> importer.body = '''<?xml version="1.0" encoding="utf-8"?>
... <object name="portal_workflow">
... <object name="one_state_workflow">
... <object name="published">
... <property name="progress">70</property>
... </object>
... </object>
... </object>'''

>>> print exporter.body
<?xml version="1.0"?>
...
<object name="one_state_workflow" meta_type="Workflow">
<object name="published" meta_type="Workflow State">
<property name="progress">70</property>
</object>
</object>
...

Override
--------
In order to prevent accidentally imports that can mess up manual customizations,
you have to add *override* attribute within property line. So if you change
progress value within the xml file, nothing should happen until
you add the override attribute.

::

>>> importer.body = '''<?xml version="1.0" encoding="utf-8"?>
... <object name="portal_workflow">
... <object name="one_state_workflow">
... <object name="published">
... <property name="progress">35</property>
... </object>
... </object>
... </object>'''

>>> print exporter.body
<?xml version="1.0"?>
...
<object name="one_state_workflow" meta_type="Workflow">
<object name="published" meta_type="Workflow State">
<property name="progress">70</property>
</object>
</object>
...

Now, let's add the override attribute. This should be used only for upgrade
steps profiles. Don't use it within the default profile, unless you know
what you're doing

::

>>> importer.body = '''<?xml version="1.0" encoding="utf-8"?>
... <object name="portal_workflow">
... <object name="one_state_workflow">
... <object name="published">
... <property name="progress" override="True">35</property>
... </object>
... </object>
... </object>'''

>>> print exporter.body
<?xml version="1.0"?>
...
<object name="one_state_workflow" meta_type="Workflow">
<object name="published" meta_type="Workflow State">
<property name="progress">35</property>
</object>
</object>
...

Remove
------
You can also remove the progress attribute

::

>>> importer.body = '''<?xml version="1.0" encoding="utf-8"?>
... <object name="portal_workflow">
... <object name="one_state_workflow">
... <object name="published">
... <property name="progress" remove="True" />
... </object>
... </object>
... </object>'''

>>> print exporter.body
<?xml version="1.0"?>
...
<object name="one_state_workflow" meta_type="Workflow">
<object name="published" meta_type="Workflow State"/>
</object>
...


Progress Bar Settings including editing progress
================================================
Expand Down
49 changes: 0 additions & 49 deletions eea/progressbar/exportimport/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,55 +4,6 @@
from zope.component import queryMultiAdapter
from Products.CMFCore.utils import getToolByName
from Products.GenericSetup.interfaces import IBody
from eea.progressbar.config import PROGRESSFILE
#
# Workflow progress
#
def importWorkflowProgress(context):
"""Import settings."""
logger = context.getLogger('eea.progressbar')

body = context.readDataFile(PROGRESSFILE)
if body is None:
logger.info("Nothing to import")
return

site = context.getSite()
tool = getToolByName(site, 'portal_workflow', None)
if not tool:
logger.info('portal_workflows tool missing')
return

importer = queryMultiAdapter((tool, context), IBody, name=PROGRESSFILE)
if importer is None:
logger.warning("Import adapter missing.")
return

# set filename on importer so that syntax errors can be reported properly
subdir = getattr(context, '_profile_path', '')
importer.filename = os.path.join(subdir, PROGRESSFILE)

importer.body = body
logger.info("Imported.")

def exportWorkflowProgress(context):
"""Export settings."""
logger = context.getLogger('eea.progressbar')
site = context.getSite()
tool = getToolByName(site, 'portal_workflow')

if tool is None:
logger.info("Nothing to export")
return

exporter = queryMultiAdapter((tool, context), IBody, name=PROGRESSFILE)
if exporter is None:
logger.warning("Export adapter missing.")
return

context.writeDataFile(PROGRESSFILE,
exporter.body, exporter.mime_type)
logger.info("Exported.")
#
# Progress Tool
#
Expand Down
22 changes: 0 additions & 22 deletions eea/progressbar/exportimport/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,6 @@
xmlns="http://namespaces.zope.org/zope"
i18n_domain="eea">

<!-- Workflow Progress -->
<adapter name="workflows.progress.xml"
factory=".progress.WorkflowToolXMLAdapter"
provides="Products.GenericSetup.interfaces.IBody"
for="eea.progressbar.interfaces.IWorkflowTool
Products.GenericSetup.interfaces.ISetupEnviron"
/>

<adapter name="workflows.progress.xml"
factory=".progress.WorkflowXMLAdapter"
provides="Products.GenericSetup.interfaces.IBody"
for="eea.progress.workflow.interfaces.IWorkflow
Products.GenericSetup.interfaces.ISetupEnviron"
/>

<adapter name="workflows.progress.xml"
factory=".progress.WorkflowStateXMLAdapter"
provides="Products.GenericSetup.interfaces.IBody"
for="eea.progress.workflow.interfaces.IWorkflowState
Products.GenericSetup.interfaces.ISetupEnviron"
/>

<!-- Progress Tool / Editing Progress -->
<adapter
factory=".tool.ProgressToolXMLAdapter"
Expand Down
120 changes: 0 additions & 120 deletions eea/progressbar/exportimport/progress.py

This file was deleted.

6 changes: 1 addition & 5 deletions eea/progressbar/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,10 @@
# Storage
from eea.progressbar.storage.interfaces import IStorage


#
# Marker interfaces
#
class IWorkflowTool(Interface):
""" Marker interface for portal_workflow
"""


class ICollection(IPloneCollection):
""" Marker interface for plone.app.collection
"""
Expand Down
15 changes: 0 additions & 15 deletions eea/progressbar/profiles.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,6 @@
<depends name="typeinfo" />
</genericsetup:importStep>

<genericsetup:importStep
name="workflow.progress.xml"
title="Workflow progress monitoring"
description="Progress monitoring based on workflow states"
handler="eea.progressbar.exportimport.importWorkflowProgress">
<depends name="workflow"/>
</genericsetup:importStep>

<genericsetup:exportStep
name="workflow.progress.xml"
title="Workflow progress monitoring"
description="Progress monitoring based on workflow states"
handler="eea.progressbar.exportimport.exportWorkflowProgress"
/>

<genericsetup:importStep
name="progressbar.xml"
title="Progress Bar Settings"
Expand Down
Loading

0 comments on commit 291e3f7

Please sign in to comment.