[CMF-checkins] SVN: CMF/branches/2.0/C Add BBB support for really
old typeinfo instances which still return mappings instead of
ActionInfos.
Tres Seaver
tseaver at palladion.com
Wed Apr 26 06:54:17 EDT 2006
Log message for revision 67615:
Add BBB support for really old typeinfo instances which still return mappings instead of ActionInfos.
Changed:
U CMF/branches/2.0/CHANGES.txt
U CMF/branches/2.0/CMFCore/exportimport/tests/test_typeinfo.py
U CMF/branches/2.0/CMFCore/exportimport/typeinfo.py
-=-
Modified: CMF/branches/2.0/CHANGES.txt
===================================================================
--- CMF/branches/2.0/CHANGES.txt 2006-04-26 10:07:05 UTC (rev 67614)
+++ CMF/branches/2.0/CHANGES.txt 2006-04-26 10:54:16 UTC (rev 67615)
@@ -1,3 +1,10 @@
+After CMF 2.0.0 (unreleased)
+
+ Bug Fixes
+
+ - CMFCore.exportimport.typeinfo: Added BBB support for really old
+ typeinfo instances which still return mappings instead of ActionInfos.
+
CMF 2.0.0 (2006/04/16)
New Features
Modified: CMF/branches/2.0/CMFCore/exportimport/tests/test_typeinfo.py
===================================================================
--- CMF/branches/2.0/CMFCore/exportimport/tests/test_typeinfo.py 2006-04-26 10:07:05 UTC (rev 67614)
+++ CMF/branches/2.0/CMFCore/exportimport/tests/test_typeinfo.py 2006-04-26 10:54:16 UTC (rev 67615)
@@ -511,16 +511,16 @@
self._compareDOM(text, _NORMAL_TOOL_EXPORT)
self.assertEqual(content_type, 'text/xml')
+ filename, text, content_type = context._wrote[1]
+ self.assertEqual(filename, 'types/foo.xml')
+ self._compareDOM(text, _FOO_EXPORT % 'foo')
+ self.assertEqual(content_type, 'text/xml')
+
filename, text, content_type = context._wrote[2]
self.assertEqual(filename, 'types/bar.xml')
self._compareDOM(text, _BAR_EXPORT % 'bar')
self.assertEqual(content_type, 'text/xml')
- filename, text, content_type = context._wrote[1]
- self.assertEqual(filename, 'types/foo.xml')
- self._compareDOM(text, _FOO_EXPORT % 'foo')
- self.assertEqual(content_type, 'text/xml')
-
def test_with_filenames(self):
from Products.CMFCore.exportimport.typeinfo import exportTypesTool
@@ -533,16 +533,47 @@
self.assertEqual(filename, 'types.xml')
self._compareDOM(text, _FILENAME_EXPORT)
self.assertEqual(content_type, 'text/xml')
+
+ filename, text, content_type = context._wrote[1]
+ self.assertEqual(filename, 'types/foo_object.xml')
+ self._compareDOM(text, _FOO_EXPORT % 'foo object')
+ self.assertEqual(content_type, 'text/xml')
+
filename, text, content_type = context._wrote[2]
self.assertEqual(filename, 'types/bar_object.xml')
self._compareDOM(text, _BAR_EXPORT % 'bar object')
self.assertEqual(content_type, 'text/xml')
+
+ def test_old_instance(self):
+ # Test for really *old* instances which still return dicts instead
+ # of action info objects
+ from Products.CMFCore.exportimport.typeinfo import exportTypesTool
+
+ site = self._initSite(1)
+ context = DummyExportContext(site)
+ foo_actions = site.portal_types.foo.listActions()
+ def _actions_as_mapping():
+ return [x.getMapping() for x in foo_actions]
+ site.portal_types.foo.listActions = _actions_as_mapping
+ exportTypesTool(context)
+
+ self.assertEqual(len(context._wrote), 3)
+ filename, text, content_type = context._wrote[0]
+ self.assertEqual(filename, 'types.xml')
+ self._compareDOM(text, _NORMAL_TOOL_EXPORT)
+ self.assertEqual(content_type, 'text/xml')
+
filename, text, content_type = context._wrote[1]
- self.assertEqual(filename, 'types/foo_object.xml')
- self._compareDOM(text, _FOO_EXPORT % 'foo object')
+ self.assertEqual(filename, 'types/foo.xml')
+ self._compareDOM(text, _FOO_EXPORT % 'foo')
self.assertEqual(content_type, 'text/xml')
+ filename, text, content_type = context._wrote[2]
+ self.assertEqual(filename, 'types/bar.xml')
+ self._compareDOM(text, _BAR_EXPORT % 'bar')
+ self.assertEqual(content_type, 'text/xml')
+
class importTypesToolTests(_TypeInfoSetup):
_EMPTY_TOOL_EXPORT = _EMPTY_TOOL_EXPORT
Modified: CMF/branches/2.0/CMFCore/exportimport/typeinfo.py
===================================================================
--- CMF/branches/2.0/CMFCore/exportimport/typeinfo.py 2006-04-26 10:07:05 UTC (rev 67614)
+++ CMF/branches/2.0/CMFCore/exportimport/typeinfo.py 2006-04-26 10:54:16 UTC (rev 67615)
@@ -110,8 +110,9 @@
def _extractActions(self):
fragment = self._doc.createDocumentFragment()
actions = self.context.listActions()
- for ai in actions:
- ai_info = ai.getMapping()
+ for ai_info in actions:
+ if not isinstance(ai_info, dict):
+ ai_info = ai_info.getMapping()
child = self._doc.createElement('action')
child.setAttribute('title', ai_info['title'])
child.setAttribute('action_id', ai_info['id'])
More information about the CMF-checkins
mailing list