[CMF-checkins] SVN: CMF/branches/1.6/CMF backported r40365 from
trunk:
Yvo Schubbe
y.2005- at wcm-solutions.de
Fri Nov 25 08:21:13 EST 2005
Log message for revision 40366:
backported r40365 from trunk:
- moved actions tool setup handlers to CMFCore
- fixed some related CMF 1.6 issues (all CMF 1.6 tests pass now)
Changed:
U CMF/branches/1.6/CMFCore/exportimport/actions.py
U CMF/branches/1.6/CMFCore/exportimport/configure.zcml
U CMF/branches/1.6/CMFCore/exportimport/tests/test_actions.py
U CMF/branches/1.6/CMFCore/exportimport/tests/test_workflow.py
U CMF/branches/1.6/CMFCore/exportimport/workflow.py
U CMF/branches/1.6/CMFDefault/profiles/default/actions.xml
U CMF/branches/1.6/CMFDefault/profiles/default/export_steps.xml
U CMF/branches/1.6/CMFDefault/profiles/default/import_steps.xml
-=-
Modified: CMF/branches/1.6/CMFCore/exportimport/actions.py
===================================================================
--- CMF/branches/1.6/CMFCore/exportimport/actions.py 2005-11-25 11:24:29 UTC (rev 40365)
+++ CMF/branches/1.6/CMFCore/exportimport/actions.py 2005-11-25 13:21:13 UTC (rev 40366)
@@ -15,88 +15,38 @@
$Id: actions.py 39947 2005-11-06 16:41:15Z yuppie $
"""
-from Products.GenericSetup.interfaces import PURGE, UPDATE
-from Products.GenericSetup.utils import I18NURI
-from Products.GenericSetup.utils import NodeAdapterBase
-from Products.GenericSetup.utils import ObjectManagerHelpers
-from Products.GenericSetup.utils import PropertyManagerHelpers
+from zope.app import zapi
-from Products.CMFCore.interfaces import IAction
-from Products.CMFCore.interfaces import IActionCategory
+from Products.GenericSetup.interfaces import IBody
+from Products.GenericSetup.interfaces import PURGE
+from Products.GenericSetup.utils import XMLAdapterBase
+
from Products.CMFCore.interfaces import IActionProvider
from Products.CMFCore.interfaces import IActionsTool
from Products.CMFCore.interfaces.portal_actions \
import ActionProvider as z2IActionProvider
from Products.CMFCore.utils import getToolByName
+_FILENAME = 'actions.xml'
-class ActionCategoryNodeAdapter(NodeAdapterBase, ObjectManagerHelpers,
- PropertyManagerHelpers):
- """Node im- and exporter for ActionCategory.
- """
+class ActionsToolXMLAdapter(XMLAdapterBase):
- __used_for__ = IActionCategory
-
- def exportNode(self, doc):
- """Export the object as a DOM node.
- """
- self._doc = doc
- node = self._getObjectNode('object')
- node.appendChild(self._extractProperties())
- node.appendChild(self._extractObjects())
- return node
-
- def importNode(self, node, mode=PURGE):
- """Import the object from the DOM node.
- """
- if mode == PURGE:
- self._purgeProperties()
- self._purgeObjects()
-
- self._initProperties(node, mode)
- self._initObjects(node, mode)
-
-
-class ActionNodeAdapter(NodeAdapterBase, PropertyManagerHelpers):
-
- """Node im- and exporter for Action.
+ """XML im- and exporter for ActionsTool.
"""
- __used_for__ = IAction
-
- def exportNode(self, doc):
- """Export the object as a DOM node.
- """
- self._doc = doc
- node = self._getObjectNode('object')
- node.appendChild(self._extractProperties())
- return node
-
- def importNode(self, node, mode=PURGE):
- """Import the object from the DOM node.
- """
- if mode == PURGE:
- self._purgeProperties()
-
- self._initProperties(node, mode)
-
-
-class ActionsToolNodeAdapter(NodeAdapterBase, ObjectManagerHelpers):
-
- """Node im- and exporter for ActionsTool.
- """
-
__used_for__ = IActionsTool
+ _LOGGER_ID = 'actions'
+
def exportNode(self, doc):
"""Export the object as a DOM node.
"""
self._doc = doc
node = self._getObjectNode('object')
- node.setAttribute('xmlns:i18n', I18NURI)
node.appendChild(self._extractProviders())
- node.appendChild(self._extractObjects())
+
+ self._logger.info('Actions tool exported.')
return node
def importNode(self, node, mode=PURGE):
@@ -104,11 +54,11 @@
"""
if mode == PURGE:
self._purgeProviders()
- self._purgeObjects()
- self._initObjects(node, mode)
self._initProviders(node, mode)
+ self._logger.info('Actions tool imported.')
+
def _extractProviders(self):
fragment = self._doc.createDocumentFragment()
for provider_id in self.context.listActionProviders():
@@ -173,18 +123,22 @@
if provider_id not in self.context.listActionProviders():
self.context.addActionProvider(provider_id)
- # delete any actions that are auto-created
- provider = getToolByName(self.context, provider_id)
- num_actions = len(provider.listActions())
- if num_actions:
- provider.deleteActions(range(0,num_actions))
+ # delete any actions that are auto-created
+ provider = getToolByName(self.context, provider_id)
+ num_actions = len(provider.listActions())
+ if num_actions:
+ provider.deleteActions(range(0,num_actions))
+
# BBB: for CMF 1.5 profiles
self._initOldstyleActions(child, mode)
def _initOldstyleActions(self, node, mode):
# BBB: for CMF 1.5 profiles
- provider = getToolByName(self.context, node.getAttribute('id'))
+ provider_id = str(node.getAttribute('name'))
+ if not provider_id:
+ provider_id = str(node.getAttribute('id'))
+ provider = getToolByName(self.context, provider_id)
for child in node.childNodes:
if child.nodeName != 'action':
continue
@@ -215,3 +169,40 @@
provider.addAction(action_id, title, url_expr,
condition_expr, permission,
category, visible)
+
+
+def importActionProviders(context):
+ """Import actions tool.
+ """
+ site = context.getSite()
+ logger = context.getLogger('actions')
+ tool = getToolByName(site, 'portal_actions')
+
+ body = context.readDataFile(_FILENAME)
+ if body is None:
+ logger.info('Nothing to import.')
+ return
+
+ importer = zapi.queryMultiAdapter((tool, context), IBody)
+ if importer is None:
+ logger.warning('Import adapter misssing.')
+ return
+
+ importer.body = body
+
+def exportActionProviders(context):
+ """Export actions tool.
+ """
+ site = context.getSite()
+ logger = context.getLogger('actions')
+ tool = getToolByName(site, 'portal_actions', None)
+ if tool is None:
+ logger.info('Nothing to export.')
+ return
+
+ exporter = zapi.queryMultiAdapter((tool, context), IBody)
+ if exporter is None:
+ logger.warning('Export adapter misssing.')
+ return
+
+ context.writeDataFile(_FILENAME, exporter.body, exporter.mime_type)
Modified: CMF/branches/1.6/CMFCore/exportimport/configure.zcml
===================================================================
--- CMF/branches/1.6/CMFCore/exportimport/configure.zcml 2005-11-25 11:24:29 UTC (rev 40365)
+++ CMF/branches/1.6/CMFCore/exportimport/configure.zcml 2005-11-25 13:21:13 UTC (rev 40366)
@@ -3,42 +3,13 @@
>
<adapter
- factory=".actions.ActionCategoryNodeAdapter"
- provides="Products.GenericSetup.interfaces.INodeExporter"
- for="Products.CMFCore.interfaces.IActionCategory"
+ factory=".actions.ActionsToolXMLAdapter"
+ provides="Products.GenericSetup.interfaces.IBody"
+ for="Products.CMFCore.interfaces.IActionsTool
+ Products.GenericSetup.interfaces.ISetupContext"
/>
<adapter
- factory=".actions.ActionCategoryNodeAdapter"
- provides="Products.GenericSetup.interfaces.INodeImporter"
- for="Products.CMFCore.interfaces.IActionCategory"
- />
-
- <adapter
- factory=".actions.ActionNodeAdapter"
- provides="Products.GenericSetup.interfaces.INodeExporter"
- for="Products.CMFCore.interfaces.IAction"
- />
-
- <adapter
- factory=".actions.ActionNodeAdapter"
- provides="Products.GenericSetup.interfaces.INodeImporter"
- for="Products.CMFCore.interfaces.IAction"
- />
-
- <adapter
- factory=".actions.ActionsToolNodeAdapter"
- provides="Products.GenericSetup.interfaces.INodeExporter"
- for="Products.CMFCore.interfaces.IActionsTool"
- />
-
- <adapter
- factory=".actions.ActionsToolNodeAdapter"
- provides="Products.GenericSetup.interfaces.INodeImporter"
- for="Products.CMFCore.interfaces.IActionsTool"
- />
-
- <adapter
factory=".cachingpolicymgr.CachingPolicyNodeAdapter"
provides="Products.GenericSetup.interfaces.INodeExporter"
for="Products.CMFCore.interfaces.ICachingPolicy"
Modified: CMF/branches/1.6/CMFCore/exportimport/tests/test_actions.py
===================================================================
--- CMF/branches/1.6/CMFCore/exportimport/tests/test_actions.py 2005-11-25 11:24:29 UTC (rev 40365)
+++ CMF/branches/1.6/CMFCore/exportimport/tests/test_actions.py 2005-11-25 13:21:13 UTC (rev 40366)
@@ -20,152 +20,128 @@
import Zope2
Zope2.startup()
+import Products
+from Acquisition import Implicit
+from Acquisition import aq_parent
+from OFS.Folder import Folder
+from OFS.OrderedFolder import OrderedFolder
+from Products.Five import zcml
+from zope.interface import implements
+
+from Products.CMFCore.ActionProviderBase import ActionProviderBase
+from Products.CMFCore.interfaces import IActionsTool
+from Products.CMFCore.interfaces.portal_actions \
+ import ActionProvider as IActionProvider
from Products.CMFCore.tests.base.dummy import DummySite
from Products.CMFCore.tests.base.testcase import PlacelessSetup
+from Products.GenericSetup.testing import BodyAdapterTestCase
from Products.GenericSetup.testing import NodeAdapterTestCase
+from Products.GenericSetup.tests.common import BaseRegistryTests
+from Products.GenericSetup.tests.common import DummyExportContext
+from Products.GenericSetup.tests.common import DummyImportContext
-try: # BBB; CMF < 2.0 doesn't have Action or ActionCategory objects
- from Products.CMFCore.ActionInformation import Action
- from Products.CMFCore.ActionInformation import ActionCategory
-except ImportError: # no such beast
- _HAVE_ACTION_OBJECTS = False
-else:
- _HAVE_ACTION_OBJECTS = True
-
-_ACTION_XML = """\
-<object name="foo_action" meta_type="CMF Action">
- <property name="title">Foo</property>
- <property name="description"></property>
- <property name="url_expr">string:${object_url}/foo</property>
- <property name="icon_expr"></property>
- <property name="available_expr">python:1</property>
- <property name="permissions"/>
- <property name="visible">True</property>
+_ACTIONSTOOL_BODY = """\
+<?xml version="1.0"?>
+<object name="portal_actions" meta_type="CMF Actions Tool">
+ <action-provider name="portal_actions"/>
</object>
"""
-_ACTIONCATEGORY_XML = """\
-<object name="foo_category" meta_type="CMF Action Category">
- <property name="title"></property>
- <object name="foo_action" meta_type="CMF Action">
- <property name="title"></property>
- <property name="description"></property>
- <property name="url_expr"></property>
- <property name="icon_expr"></property>
- <property name="available_expr"></property>
- <property name="permissions"/>
- <property name="visible">True</property>
- </object>
+_EMPTY_EXPORT = """\
+<?xml version="1.0"?>
+<object meta_type="CMF Actions Tool" name="portal_actions">
+ <action-provider name="portal_actions"/>
</object>
"""
-_ACTIONSTOOL_XML = """\
-<object name="portal_actions" meta_type="CMF Actions Tool"
- xmlns:i18n="http://xml.zope.org/namespaces/i18n">
+_NORMAL_EXPORT = """\
+<?xml version="1.0"?>
+<object meta_type="CMF Actions Tool" name="portal_actions">
<action-provider name="portal_actions"/>
- <object name="foo_category" meta_type="CMF Action Category">
- <property name="title"></property>
- <object name="foo_action" meta_type="CMF Action" i18n:domain="foo_domain">
- <property name="title" i18n:translate=""></property>
- <property name="description" i18n:translate=""></property>
- <property name="url_expr"></property>
- <property name="icon_expr"></property>
- <property name="available_expr"></property>
- <property name="permissions"/>
- <property name="visible">True</property>
- </object>
- </object>
+ <action-provider name="portal_foo">
+ <action action_id="foo"
+ title="Foo"
+ url_expr="string:${object_url}/foo"
+ condition_expr="python:1"
+ category="dummy"
+ visible="True"/>
+ </action-provider>
+ <action-provider name="portal_bar">
+ <action action_id="bar"
+ title="Bar"
+ url_expr="string:${object_url}/bar"
+ condition_expr="python:0"
+ category="dummy"
+ visible="False">
+ <permission>Manage portal</permission>
+ </action>
+ </action-provider>
</object>
"""
+_REMOVE_IMPORT = """\
+<?xml version="1.0"?>
+<actions-tool>
+ <action-provider id="portal_actions" remove="">
+ </action-provider>
+ <action-provider id="not_existing" remove="">
+ </action-provider>
+ <action-provider id="portal_bar" remove="">
+ </action-provider>
+</actions-tool>
+"""
-class ActionNodeAdapterTests(PlacelessSetup, NodeAdapterTestCase):
- def _getTargetClass(self):
- from Products.CMFCore.exportimport.actions import ActionNodeAdapter
+class DummyTool(OrderedFolder, ActionProviderBase):
- return ActionNodeAdapter
+ __implements__ = IActionProvider
- def _populate(self, obj):
- obj._setPropValue('title', 'Foo')
- obj._setPropValue('url_expr', 'string:${object_url}/foo')
- obj._setPropValue('available_expr', 'python:1')
- def _verifyImport(self, obj):
- self.assertEqual(type(obj.title), str)
- self.assertEqual(obj.title, 'Foo')
- self.assertEqual(type(obj.description), str)
- self.assertEqual(obj.description, '')
- self.assertEqual(type(obj.url_expr), str)
- self.assertEqual(obj.url_expr, 'string:${object_url}/foo')
- self.assertEqual(type(obj.icon_expr), str)
- self.assertEqual(obj.icon_expr, '')
- self.assertEqual(type(obj.available_expr), str)
- self.assertEqual(obj.available_expr, 'python:1')
- self.assertEqual(type(obj.permissions), tuple)
- self.assertEqual(obj.permissions, ())
- self.assertEqual(type(obj.visible), bool)
- self.assertEqual(obj.visible, True)
+class DummyUser(Implicit):
- def setUp(self):
- import Products.CMFCore.exportimport
- import Products.Five
- from Products.Five import zcml
+ def getId(self):
+ return 'dummy'
- PlacelessSetup.setUp(self)
- zcml.load_config('meta.zcml', Products.Five)
- zcml.load_config('configure.zcml', Products.CMFCore.exportimport)
- self._obj = Action('foo_action')
- self._XML = _ACTION_XML
+class DummyMembershipTool(DummyTool):
+ def isAnonymousUser(self):
+ return False
-class ActionCategoryNodeAdapterTests(PlacelessSetup, NodeAdapterTestCase):
+ def getAuthenticatedMember(self):
+ return DummyUser().__of__(aq_parent(self))
- def _getTargetClass(self):
- from Products.CMFCore.exportimport.actions \
- import ActionCategoryNodeAdapter
- return ActionCategoryNodeAdapter
+class DummyActionsTool(DummyTool):
- def _populate(self, obj):
- from Products.CMFCore.ActionInformation import Action
+ implements(IActionsTool)
+ id = 'portal_actions'
+ meta_type = 'CMF Actions Tool'
- obj._setObject('foo_action', Action('foo_action'))
+ def __init__(self):
+ self._providers = []
- def _verifyImport(self, obj):
- self.assertEqual(type(obj.title), str)
- self.assertEqual(obj.title, '')
+ def addActionProvider(self, provider_name):
+ self._providers.append(provider_name)
- def setUp(self):
- import Products.CMFCore.exportimport
- import Products.Five
- from Products.Five import zcml
+ def listActionProviders(self):
+ return self._providers[:]
- PlacelessSetup.setUp(self)
- zcml.load_config('meta.zcml', Products.Five)
- zcml.load_config('configure.zcml', Products.CMFCore.exportimport)
+ def deleteActionProvider(self, provider_name):
+ self._providers = [ x for x in self._providers if x != provider_name ]
- self._obj = ActionCategory('foo_category')
- self._XML = _ACTIONCATEGORY_XML
+class ActionsToolXMLAdapterTests(BodyAdapterTestCase):
-class ActionsToolNodeAdapterTests(PlacelessSetup, NodeAdapterTestCase):
-
def _getTargetClass(self):
from Products.CMFCore.exportimport.actions \
- import ActionsToolNodeAdapter
+ import ActionsToolXMLAdapter
- return ActionsToolNodeAdapter
+ return ActionsToolXMLAdapter
def _populate(self, obj):
- from Products.CMFCore.ActionInformation import Action
- from Products.CMFCore.ActionInformation import ActionCategory
-
- obj._setObject('foo_category', ActionCategory('foo_category'))
obj.action_providers = ('portal_actions',)
- obj.foo_category._setObject('foo_action', Action('foo_action'))
- obj.foo_category.foo_action.i18n_domain = 'foo_domain'
+ obj._actions = ()
def _verifyImport(self, obj):
self.assertEqual(type(obj.action_providers), tuple)
@@ -174,28 +150,223 @@
self.assertEqual(obj.action_providers[0], 'portal_actions')
def setUp(self):
+ import Products.CMFCore.exportimport
from Products.CMFCore.ActionsTool import ActionsTool
- import Products.CMFCore.exportimport
- import Products.Five
- from Products.Five import zcml
- PlacelessSetup.setUp(self)
- zcml.load_config('meta.zcml', Products.Five)
+ BodyAdapterTestCase.setUp(self)
zcml.load_config('configure.zcml', Products.CMFCore.exportimport)
site = DummySite('site')
site._setObject('portal_actions', ActionsTool('portal_actions'))
self._obj = site.portal_actions
- self._XML = _ACTIONSTOOL_XML
+ self._BODY = _ACTIONSTOOL_BODY
+class _ActionSetup(PlacelessSetup, BaseRegistryTests):
+
+ def _initSite(self, foo=2, bar=2):
+ self.root.site = Folder(id='site')
+ site = self.root.site
+ site.portal_membership = DummyMembershipTool()
+
+ site.portal_actions = DummyActionsTool()
+ site.portal_actions.addActionProvider('portal_actions')
+
+ if foo > 0:
+ site.portal_foo = DummyTool()
+
+ if foo > 1:
+ site.portal_foo.addAction(id='foo',
+ name='Foo',
+ action='foo',
+ condition='python:1',
+ permission=(),
+ category='dummy',
+ visible=1)
+ site.portal_actions.addActionProvider('portal_foo')
+
+ if bar > 0:
+ site.portal_bar = DummyTool()
+
+ if bar > 1:
+ site.portal_bar.addAction(id='bar',
+ name='Bar',
+ action='bar',
+ condition='python:0',
+ permission=('Manage portal',),
+ category='dummy',
+ visible=0)
+ site.portal_actions.addActionProvider('portal_bar')
+
+ return site
+
+ def setUp(self):
+ PlacelessSetup.setUp(self)
+ BaseRegistryTests.setUp(self)
+ zcml.load_config('meta.zcml', Products.Five)
+ zcml.load_config('configure.zcml', Products.CMFCore.exportimport)
+
+ def tearDown(self):
+ BaseRegistryTests.tearDown(self)
+ PlacelessSetup.tearDown(self)
+
+
+class exportActionProvidersTests(_ActionSetup):
+
+ def test_unchanged(self):
+ from Products.CMFCore.exportimport.actions \
+ import exportActionProviders
+
+ site = self._initSite(0, 0)
+ context = DummyExportContext(site)
+ exportActionProviders(context)
+
+ self.assertEqual(len(context._wrote), 1)
+ filename, text, content_type = context._wrote[0]
+ self.assertEqual(filename, 'actions.xml')
+ self._compareDOM(text, _EMPTY_EXPORT)
+ self.assertEqual(content_type, 'text/xml')
+
+ def test_normal(self):
+ from Products.CMFCore.exportimport.actions \
+ import exportActionProviders
+
+ site = self._initSite()
+
+ context = DummyExportContext(site)
+ exportActionProviders(context)
+
+ self.assertEqual(len(context._wrote), 1)
+
+ filename, text, content_type = context._wrote[0]
+ self.assertEqual(filename, 'actions.xml')
+ self._compareDOM(text, _NORMAL_EXPORT)
+ self.assertEqual(content_type, 'text/xml')
+
+
+class importActionProvidersTests(_ActionSetup):
+
+ def test_empty_default_purge(self):
+ from Products.CMFCore.exportimport.actions \
+ import importActionProviders
+
+ site = self._initSite(2, 0)
+ atool = site.portal_actions
+
+ self.assertEqual(len(atool.listActionProviders()), 2)
+ self.failUnless('portal_foo' in atool.listActionProviders())
+ self.failUnless('portal_actions' in atool.listActionProviders())
+
+ context = DummyImportContext(site)
+ context._files['actions.xml'] = _EMPTY_EXPORT
+ importActionProviders(context)
+
+ self.assertEqual(len(atool.listActionProviders()), 1)
+ self.failIf('portal_foo' in atool.listActionProviders())
+ self.failUnless('portal_actions' in atool.listActionProviders())
+ self.assertEqual(len(atool.objectIds()), 0)
+
+ def test_empty_explicit_purge(self):
+ from Products.CMFCore.exportimport.actions \
+ import importActionProviders
+
+ site = self._initSite(2, 0)
+ atool = site.portal_actions
+
+ self.assertEqual(len(atool.listActionProviders()), 2)
+ self.failUnless('portal_foo' in atool.listActionProviders())
+ self.failUnless('portal_actions' in atool.listActionProviders())
+
+ context = DummyImportContext(site, True)
+ context._files['actions.xml'] = _EMPTY_EXPORT
+ importActionProviders(context)
+
+ self.assertEqual(len(atool.listActionProviders()), 1)
+ self.failIf('portal_foo' in atool.listActionProviders())
+ self.failUnless('portal_actions' in atool.listActionProviders())
+ self.assertEqual(len(atool.objectIds()), 0)
+
+ def test_empty_skip_purge(self):
+ from Products.CMFCore.exportimport.actions \
+ import importActionProviders
+
+ site = self._initSite(2, 0)
+ atool = site.portal_actions
+
+ self.assertEqual(len(atool.listActionProviders()), 2)
+ self.failUnless('portal_foo' in atool.listActionProviders())
+ self.failUnless('portal_actions' in atool.listActionProviders())
+
+ context = DummyImportContext(site, False)
+ context._files['actions.xml'] = _EMPTY_EXPORT
+ importActionProviders(context)
+
+ self.assertEqual(len(atool.listActionProviders()), 2)
+ self.failUnless('portal_foo' in atool.listActionProviders())
+ self.failUnless('portal_actions' in atool.listActionProviders())
+
+ def test_normal(self):
+ from Products.CMFCore.exportimport.actions \
+ import exportActionProviders
+ from Products.CMFCore.exportimport.actions \
+ import importActionProviders
+
+ site = self._initSite(1, 1)
+ atool = site.portal_actions
+ foo = site.portal_foo
+ bar = site.portal_bar
+
+ self.assertEqual(len(atool.listActionProviders()), 1)
+ self.failIf('portal_foo' in atool.listActionProviders())
+ self.failIf(foo.listActions())
+ self.failIf('portal_bar' in atool.listActionProviders())
+ self.failIf(bar.listActions())
+ self.failUnless('portal_actions' in atool.listActionProviders())
+
+ context = DummyImportContext(site)
+ context._files['actions.xml'] = _NORMAL_EXPORT
+ importActionProviders(context)
+
+ self.assertEqual(len(atool.listActionProviders()), 3)
+ self.failUnless('portal_actions' in atool.listActionProviders())
+ self.failUnless('portal_foo' in atool.listActionProviders())
+ self.failUnless(foo.listActions())
+ self.failUnless('portal_bar' in atool.listActionProviders())
+ self.failUnless(bar.listActions())
+
+ # complete the roundtrip
+ context = DummyExportContext(site)
+ exportActionProviders(context)
+
+ self.assertEqual(len(context._wrote), 1)
+ filename, text, content_type = context._wrote[0]
+ self.assertEqual(filename, 'actions.xml')
+ self._compareDOM(text, _NORMAL_EXPORT)
+ self.assertEqual(content_type, 'text/xml')
+
+ def test_remove_skip_purge(self):
+ from Products.CMFCore.exportimport.actions \
+ import importActionProviders
+
+ site = self._initSite(2, 2)
+ atool = site.portal_actions
+
+ self.assertEqual(atool.listActionProviders(),
+ ['portal_actions', 'portal_foo', 'portal_bar'])
+
+ context = DummyImportContext(site, False)
+ context._files['actions.xml'] = _REMOVE_IMPORT
+ importActionProviders(context)
+
+ self.assertEqual(atool.listActionProviders(), ['portal_foo'])
+
+
def test_suite():
- suite = unittest.TestSuite()
- if _HAVE_ACTION_OBJECTS:
- suite.addTest(unittest.makeSuite(ActionNodeAdapterTests))
- suite.addTest(unittest.makeSuite(ActionCategoryNodeAdapterTests))
- suite.addTest(unittest.makeSuite(ActionsToolNodeAdapterTests))
- return suite
+ return unittest.TestSuite((
+ unittest.makeSuite(ActionsToolXMLAdapterTests),
+ unittest.makeSuite(exportActionProvidersTests),
+ unittest.makeSuite(importActionProvidersTests),
+ ))
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
Modified: CMF/branches/1.6/CMFCore/exportimport/tests/test_workflow.py
===================================================================
--- CMF/branches/1.6/CMFCore/exportimport/tests/test_workflow.py 2005-11-25 11:24:29 UTC (rev 40365)
+++ CMF/branches/1.6/CMFCore/exportimport/tests/test_workflow.py 2005-11-25 13:21:13 UTC (rev 40366)
@@ -219,6 +219,7 @@
BaseRegistryTests.tearDown(self)
PlacelessSetup.tearDown(self)
+
class exportWorkflowToolTests(_WorkflowSetup):
def test_empty(self):
@@ -283,7 +284,6 @@
context = DummyImportContext(site)
context._files['workflows.xml'] = self._EMPTY_TOOL_EXPORT
-
importWorkflowTool(context)
self.assertEqual(len(wf_tool.objectIds()), 0)
Modified: CMF/branches/1.6/CMFCore/exportimport/workflow.py
===================================================================
--- CMF/branches/1.6/CMFCore/exportimport/workflow.py 2005-11-25 11:24:29 UTC (rev 40365)
+++ CMF/branches/1.6/CMFCore/exportimport/workflow.py 2005-11-25 13:21:13 UTC (rev 40366)
@@ -29,14 +29,13 @@
from Products.CMFCore.interfaces import IWorkflowTool
from Products.CMFCore.utils import getToolByName
-
_FILENAME = 'workflows.xml'
class WorkflowToolXMLAdapter(XMLAdapterBase, ObjectManagerHelpers,
PropertyManagerHelpers):
- """Node im- and exporter for WorkflowTool.
+ """XML im- and exporter for WorkflowTool.
"""
__used_for__ = IWorkflowTool
Modified: CMF/branches/1.6/CMFDefault/profiles/default/actions.xml
===================================================================
--- CMF/branches/1.6/CMFDefault/profiles/default/actions.xml 2005-11-25 11:24:29 UTC (rev 40365)
+++ CMF/branches/1.6/CMFDefault/profiles/default/actions.xml 2005-11-25 13:21:13 UTC (rev 40366)
@@ -1,107 +1,91 @@
<?xml version="1.0"?>
-<actions-tool>
- <action-provider id="portal_membership">
- <action action_id="login" title="Login"
- condition_expr="not: member"
- url_expr="string:${portal_url}/login_form"
- category="user" visible="True">
+<object name="portal_actions" meta_type="CMF Actions Tool">
+ <action-provider name="portal_membership">
+ <action title="Login" action_id="login" category="user"
+ condition_expr="not: member" url_expr="string:${portal_url}/login_form"
+ visible="True">
<permission>View</permission>
</action>
- <action action_id="preferences" title="Preferences"
- condition_expr="member"
- url_expr="string:${portal_url}/personalize_form"
- category="user" visible="True">
+ <action title="Preferences" action_id="preferences" category="user"
+ condition_expr="member" url_expr="string:${portal_url}/personalize_form"
+ visible="True">
<permission>View</permission>
</action>
- <action action_id="logout" title="Log out"
- condition_expr="member"
- url_expr="string:${portal_url}/logout"
- category="user" visible="True">
+ <action title="Log out" action_id="logout" category="user"
+ condition_expr="member" url_expr="string:${portal_url}/logout"
+ visible="True">
<permission>View</permission>
</action>
- <action action_id="addFavorite" title="Add to favorites"
- condition_expr="portal/portal_membership/getHomeFolder"
- url_expr="string:${object_url}/addtoFavorites"
- category="user" visible="True">
+ <action title="Add to favorites" action_id="addFavorite" category="user"
+ condition_expr="portal/portal_membership/getHomeFolder"
+ url_expr="string:${object_url}/addtoFavorites" visible="True">
<permission>View</permission>
</action>
- <action action_id="mystuff" title="My stuff"
- condition_expr="python: member and portal.portal_membership.getHomeFolder()"
- url_expr="string:${portal/portal_membership/getHomeUrl}/folder_contents"
- category="user" visible="True">
+ <action title="My stuff" action_id="mystuff" category="user"
+ condition_expr="python: member and portal.portal_membership.getHomeFolder()"
+ url_expr="string:${portal/portal_membership/getHomeUrl}/folder_contents"
+ visible="True">
<permission>View</permission>
</action>
- <action action_id="favorites" title="My favorites"
- condition_expr="python: member and hasattr(portal.portal_membership.getHomeFolder(), "Favorites")"
- url_expr="string:${portal/portal_membership/getHomeUrl}/Favorites/folder_contents"
- category="user" visible="True">
+ <action title="My favorites" action_id="favorites" category="user"
+ condition_expr="python: member and hasattr(portal.portal_membership.getHomeFolder(), "Favorites")"
+ url_expr="string:${portal/portal_membership/getHomeUrl}/Favorites/folder_contents"
+ visible="True">
<permission>View</permission>
</action>
- <action action_id="manage_members" title="Manage members"
- condition_expr=""
- url_expr="string:${portal_url}/members_manage_form"
- category="global" visible="True">
+ <action title="Manage members" action_id="manage_members" category="global"
+ condition_expr="" url_expr="string:${portal_url}/members_manage_form"
+ visible="True">
<permission>Manage users</permission>
</action>
- <action action_id="logged_in" title="Logged in"
- condition_expr=""
- url_expr="string:${portal_url}/logged_in"
- category="user" visible="False">
+ <action title="Logged in" action_id="logged_in" category="user"
+ condition_expr="" url_expr="string:${portal_url}/logged_in"
+ visible="False">
<permission>View</permission>
</action>
</action-provider>
- <action-provider id="portal_actions">
- <action action_id="folderContents" title="Folder contents"
- condition_expr="python: folder is not object"
- url_expr="string:${folder_url}/folder_contents"
- category="folder" visible="True">
+ <action-provider name="portal_actions">
+ <action title="Folder contents" action_id="folderContents" category="folder"
+ condition_expr="python: folder is not object"
+ url_expr="string:${folder_url}/folder_contents" visible="True">
<permission>List folder contents</permission>
</action>
</action-provider>
- <action-provider id="portal_registration">
- <action action_id="join" title="Join"
- condition_expr="not: member"
- url_expr="string:${portal_url}/join_form"
- category="user" visible="True">
+ <action-provider name="portal_registration">
+ <action title="Join" action_id="join" category="user"
+ condition_expr="not: member" url_expr="string:${portal_url}/join_form"
+ visible="True">
<permission>Add portal member</permission>
</action>
</action-provider>
- <action-provider id="portal_types">
-
- </action-provider>
- <action-provider id="portal_discussion">
- <action action_id="reply" title="Reply"
- condition_expr="python: object is not None and portal.portal_discussion.isDiscussionAllowedFor(object)"
- url_expr="string:${object_url}/discussion_reply_form"
- category="object" visible="True">
+ <action-provider name="portal_types"/>
+ <action-provider name="portal_discussion">
+ <action title="Reply" action_id="reply" category="object"
+ condition_expr="python: object is not None and portal.portal_discussion.isDiscussionAllowedFor(object)"
+ url_expr="string:${object_url}/discussion_reply_form" visible="True">
<permission>Reply to item</permission>
</action>
</action-provider>
- <action-provider id="portal_undo">
- <action action_id="undo" title="Undo"
- condition_expr="member"
- url_expr="string:${portal_url}/undo_form"
- category="global" visible="True">
+ <action-provider name="portal_undo">
+ <action title="Undo" action_id="undo" category="global"
+ condition_expr="member" url_expr="string:${portal_url}/undo_form"
+ visible="True">
<permission>List undoable changes</permission>
</action>
</action-provider>
- <action-provider id="portal_syndication">
- <action action_id="syndication" title="Syndication"
- condition_expr="python: folder is object"
- url_expr="string:${folder_url}/synPropertiesForm"
- category="object" visible="True">
+ <action-provider name="portal_syndication">
+ <action title="Syndication" action_id="syndication" category="object"
+ condition_expr="python: folder is object"
+ url_expr="string:${folder_url}/synPropertiesForm" visible="True">
<permission>Manage properties</permission>
</action>
</action-provider>
- <action-provider id="portal_workflow">
-
- </action-provider>
- <action-provider id="portal_properties">
- <action action_id="configPortal"
- title="Reconfigure Portal" condition_expr=""
- url_expr="string:${portal_url}/reconfig_form"
- category="global" visible="True">
+ <action-provider name="portal_workflow"/>
+ <action-provider name="portal_properties">
+ <action title="Reconfigure Portal" action_id="configPortal"
+ category="global" condition_expr=""
+ url_expr="string:${portal_url}/reconfig_form" visible="True">
<permission>Manage portal</permission>
</action>
</action-provider>
-</actions-tool>
+</object>
Modified: CMF/branches/1.6/CMFDefault/profiles/default/export_steps.xml
===================================================================
--- CMF/branches/1.6/CMFDefault/profiles/default/export_steps.xml 2005-11-25 11:24:29 UTC (rev 40365)
+++ CMF/branches/1.6/CMFDefault/profiles/default/export_steps.xml 2005-11-25 13:21:13 UTC (rev 40366)
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<export-steps>
<export-step id="actions"
- handler="Products.CMFSetup.actions.exportActionProviders"
+ handler="Products.CMFCore.exportimport.actions.exportActionProviders"
title="Action Providers">
Export actions tool's action providers and their actions.
</export-step>
Modified: CMF/branches/1.6/CMFDefault/profiles/default/import_steps.xml
===================================================================
--- CMF/branches/1.6/CMFDefault/profiles/default/import_steps.xml 2005-11-25 11:24:29 UTC (rev 40365)
+++ CMF/branches/1.6/CMFDefault/profiles/default/import_steps.xml 2005-11-25 13:21:13 UTC (rev 40366)
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<import-steps>
<import-step id="actions" version="20040630-01"
- handler="Products.CMFSetup.actions.importActionProviders"
+ handler="Products.CMFCore.exportimport.actions.importActionProviders"
title="Action Providers">
<dependency step="toolset"/>
Import actions tool's action providers and their actions.
More information about the CMF-checkins
mailing list