[Checkins] SVN: Products.CMFCore/trunk/Products/CMFCore/ - removed redundant 'content_icon' property
Yvo Schubbe
y.2009 at wcm-solutions.de
Fri Nov 20 04:32:54 EST 2009
Log message for revision 105900:
- removed redundant 'content_icon' property
Changed:
U Products.CMFCore/trunk/Products/CMFCore/CHANGES.txt
U Products.CMFCore/trunk/Products/CMFCore/TypesTool.py
U Products.CMFCore/trunk/Products/CMFCore/exportimport/tests/test_typeinfo.py
U Products.CMFCore/trunk/Products/CMFCore/exportimport/typeinfo.py
-=-
Modified: Products.CMFCore/trunk/Products/CMFCore/CHANGES.txt
===================================================================
--- Products.CMFCore/trunk/Products/CMFCore/CHANGES.txt 2009-11-20 08:13:54 UTC (rev 105899)
+++ Products.CMFCore/trunk/Products/CMFCore/CHANGES.txt 2009-11-20 09:32:54 UTC (rev 105900)
@@ -4,6 +4,11 @@
2.2.0-beta (unreleased)
-----------------------
+- TypeInformation: Removed redundant 'content_icon' property.
+ For backwards compatibility old settings containing 'content_icon' instead
+ of 'icon_expr' are converted on import. CMFDefault provides the necessary
+ upgrade steps for migrating existing sites.
+
- DynamicType: Added 'getIconURL' method.
This replaces the now deprecated 'getIcon' method.
Modified: Products.CMFCore/trunk/Products/CMFCore/TypesTool.py
===================================================================
--- Products.CMFCore/trunk/Products/CMFCore/TypesTool.py 2009-11-20 08:13:54 UTC (rev 105899)
+++ Products.CMFCore/trunk/Products/CMFCore/TypesTool.py 2009-11-20 09:32:54 UTC (rev 105900)
@@ -88,8 +88,6 @@
'label':'Description'},
{'id':'i18n_domain', 'type': 'string', 'mode':'w',
'label':'I18n Domain'},
- {'id':'content_icon', 'type': 'string', 'mode':'w',
- 'label':'Icon'},
{'id': 'icon_expr', 'type': 'string', 'mode': 'w',
'label': 'Icon (Expression)'},
{'id':'content_meta_type', 'type': 'string', 'mode':'w',
@@ -122,7 +120,6 @@
description = ''
i18n_domain = ''
content_meta_type = ''
- content_icon = ''
icon_expr = ''
add_view_expr = ''
immediate_view = ''
Modified: Products.CMFCore/trunk/Products/CMFCore/exportimport/tests/test_typeinfo.py
===================================================================
--- Products.CMFCore/trunk/Products/CMFCore/exportimport/tests/test_typeinfo.py 2009-11-20 08:13:54 UTC (rev 105899)
+++ Products.CMFCore/trunk/Products/CMFCore/exportimport/tests/test_typeinfo.py 2009-11-20 09:32:54 UTC (rev 105900)
@@ -40,7 +40,6 @@
xmlns:i18n="http://xml.zope.org/namespaces/i18n">
<property name="title"></property>
<property name="description"></property>
- <property name="content_icon"></property>
<property name="icon_expr"></property>
<property name="content_meta_type"></property>
<property name="product"></property>
@@ -74,7 +73,6 @@
'description': 'Foo things',
'i18n_domain': 'foo_domain',
'content_meta_type': 'Foo Thing',
- 'content_icon': 'foo.png',
'icon_expr': 'string:${portal_url}/foo.png',
'product': 'CMFSetup',
'factory': 'addFoo',
@@ -113,7 +111,6 @@
'title': 'Bar',
'description': 'Bar things',
'content_meta_type': 'Bar Thing',
- 'content_icon': 'bar.png',
'icon_expr': 'string:${portal_url}/bar.png',
'constructor_path': 'make_bar',
'permission': 'Add portal content',
@@ -195,7 +192,6 @@
i18n:domain="foo_domain" xmlns:i18n="http://xml.zope.org/namespaces/i18n">
<property name="title" i18n:translate="">Foo</property>
<property name="description" i18n:translate="">Foo things</property>
- <property name="content_icon">foo.png</property>
<property name="icon_expr">string:${portal_url}/foo.png</property>
<property name="content_meta_type">Foo Thing</property>
<property name="product">CMFSetup</property>
@@ -236,7 +232,6 @@
xmlns:i18n="http://xml.zope.org/namespaces/i18n">
<property name="title">Bar</property>
<property name="description">Bar things</property>
- <property name="content_icon">bar.png</property>
<property name="icon_expr">string:${portal_url}/bar.png</property>
<property name="content_meta_type">Bar Thing</property>
<property name="permission">Add portal content</property>
@@ -275,6 +270,50 @@
</object>
"""
+_BAR_CMF21_IMPORT = """\
+<?xml version="1.0"?>
+<object name="%s" meta_type="Scriptable Type Information"
+ xmlns:i18n="http://xml.zope.org/namespaces/i18n">
+ <property name="title">Bar</property>
+ <property name="description">Bar things</property>
+ <property name="content_icon">bar.png</property>
+ <property name="content_meta_type">Bar Thing</property>
+ <property name="permission">Add portal content</property>
+ <property name="constructor_path">make_bar</property>
+ <property name="add_view_expr">string:${folder_url}/bar_add_view</property>
+ <property name="link_target"/>
+ <property name="immediate_view">bar_view</property>
+ <property name="global_allow">True</property>
+ <property name="filter_content_types">True</property>
+ <property name="allowed_content_types">
+ <element value="foo"/>
+ </property>
+ <property name="allow_discussion">True</property>
+ <alias from="(Default)" to="bar_view"/>
+ <alias from="view" to="bar_view"/>
+ <action title="View" action_id="view" category="object" condition_expr=""
+ url_expr="string:${object_url}/bar_view"
+ icon_expr="" link_target="" visible="True">
+ <permission value="View"/>
+ </action>
+ <action title="Edit" action_id="edit" category="object" condition_expr=""
+ url_expr="string:${object_url}/bar_edit_form"
+ icon_expr="" link_target="" visible="True">
+ <permission value="Modify portal content"/>
+ </action>
+ <action title="Contents" action_id="contents" category="object"
+ condition_expr="" url_expr="string:${object_url}/folder_contents"
+ icon_expr="" link_target="" visible="True">
+ <permission value="Access contents information"/>
+ </action>
+ <action title="Metadata" action_id="metadata" category="object"
+ condition_expr="" url_expr="string:${object_url}/metadata_edit_form"
+ icon_expr="" link_target="" visible="True">
+ <permission value="Modify portal content"/>
+ </action>
+</object>
+"""
+
_UPDATE_FOO_IMPORT = """\
<object name="foo">
<alias from="spam" to="eggs"/>
@@ -527,6 +566,25 @@
self.failUnless('foo object' in tool.objectIds())
self.failUnless('bar object' in tool.objectIds())
+ def test_migration(self):
+ from Products.CMFCore.exportimport.typeinfo import importTypesTool
+
+ site = self._initSite()
+ tool = site.portal_types
+
+ self.assertEqual(len(tool.objectIds()), 0)
+
+ context = DummyImportContext(site)
+ context._files['types.xml'] = self._NORMAL_TOOL_EXPORT
+ context._files['types/foo.xml'] = _FOO_EXPORT % 'foo'
+ context._files['types/bar.xml'] = _BAR_CMF21_IMPORT % 'bar'
+ importTypesTool(context)
+
+ self.assertEqual(len(tool.objectIds()), 2)
+ self.failUnless('foo' in tool.objectIds())
+ self.failUnless('bar' in tool.objectIds())
+ self.assertEqual(tool.bar.icon_expr, 'string:${portal_url}/bar.png')
+
def test_normal_update(self):
from Products.CMFCore.exportimport.typeinfo import importTypesTool
@@ -541,7 +599,7 @@
self.assertEqual(tool.foo.title, 'Foo')
self.assertEqual(tool.foo.content_meta_type, 'Foo Thing')
- self.assertEqual(tool.foo.content_icon, 'foo.png')
+ self.assertEqual(tool.foo.icon_expr, 'string:${portal_url}/foo.png')
self.assertEqual(tool.foo.immediate_view, 'foo_view')
self.assertEqual(tool.foo._aliases,
{'(Default)': 'foo_view', 'view': 'foo_view'})
@@ -553,7 +611,7 @@
self.assertEqual(tool.foo.title, 'Foo')
self.assertEqual(tool.foo.content_meta_type, 'Foo Thing')
- self.assertEqual(tool.foo.content_icon, 'foo.png')
+ self.assertEqual(tool.foo.icon_expr, 'string:${portal_url}/foo.png')
self.assertEqual(tool.foo.immediate_view, 'foo_view')
self.assertEqual(tool.foo._aliases,
{'(Default)': 'foo_view', 'view': 'foo_view', 'spam': 'eggs'})
Modified: Products.CMFCore/trunk/Products/CMFCore/exportimport/typeinfo.py
===================================================================
--- Products.CMFCore/trunk/Products/CMFCore/exportimport/typeinfo.py 2009-11-20 08:13:54 UTC (rev 105899)
+++ Products.CMFCore/trunk/Products/CMFCore/exportimport/typeinfo.py 2009-11-20 09:32:54 UTC (rev 105900)
@@ -59,6 +59,7 @@
self._purgeAliases()
self._purgeActions()
+ self._migrateProperties(node)
self._initProperties(node)
self._initAliases(node)
self._initActions(node)
@@ -66,6 +67,24 @@
obj_id = str(node.getAttribute('name'))
self._logger.info('%r type info imported.' % obj_id)
+ def _migrateProperties(self, node):
+ # BBB: for CMF 2.1 icon settings
+ for child in node.childNodes:
+ if child.nodeName != 'property':
+ continue
+ if child.getAttribute('name') == 'icon_expr':
+ return
+ for child in node.childNodes:
+ if child.nodeName != 'property':
+ continue
+ if child.getAttribute('name') != 'content_icon':
+ continue
+ icon = 'string:${portal_url}/%s' % self._getNodeText(child)
+ new_child = self._doc.createElement('property')
+ new_child.setAttribute('name', 'icon_expr')
+ new_child.appendChild(self._doc.createTextNode(icon))
+ node.replaceChild(new_child, child)
+
def _extractAliases(self):
fragment = self._doc.createDocumentFragment()
aliases = self.context.getMethodAliases().items()
More information about the checkins
mailing list