[Checkins] SVN: CMF/branches/2.1/CMFActionIcons/ Adjusted the
exportimport handler to tolerate TAL-like i18n markup,
which can be used to extract messages from profiles automatically,
which is for example implemented in i18ndude.
Hanno Schlichting
plone at hannosch.info
Mon May 21 13:40:54 EDT 2007
Log message for revision 75863:
Adjusted the exportimport handler to tolerate TAL-like i18n markup, which can be used to extract messages from profiles automatically, which is for example implemented in i18ndude.
Changed:
U CMF/branches/2.1/CMFActionIcons/exportimport.py
U CMF/branches/2.1/CMFActionIcons/tests/test_exportimport.py
-=-
Modified: CMF/branches/2.1/CMFActionIcons/exportimport.py
===================================================================
--- CMF/branches/2.1/CMFActionIcons/exportimport.py 2007-05-21 17:31:13 UTC (rev 75862)
+++ CMF/branches/2.1/CMFActionIcons/exportimport.py 2007-05-21 17:40:54 UTC (rev 75863)
@@ -66,6 +66,9 @@
for action_icon in ait_info['action_icons']:
category = action_icon['category']
action_id = action_icon['action_id']
+ # Ignore the i18n markup
+ if action_icon.get('i18n:attributes', None) is not None:
+ del action_icon['i18n:attributes']
if ait.queryActionInfo(category, action_id) is not None:
ait.updateActionIcon(**action_icon)
else:
@@ -117,13 +120,17 @@
def _getImportMapping(self):
return {
'action-icons':
- { 'action-icon': {KEY: 'action_icons', DEFAULT: ()} },
+ { 'action-icon': {KEY: 'action_icons', DEFAULT: ()},
+ 'i18n:domain': {},
+ 'xmlns:i18n': {},
+ },
'action-icon':
- { 'category': {},
- 'action_id': {},
- 'title': {},
- 'icon_expr': {},
- 'priority': {CONVERTER: self._convertToInteger},
+ { 'category': {},
+ 'action_id': {},
+ 'title': {},
+ 'icon_expr': {},
+ 'priority': {CONVERTER: self._convertToInteger},
+ 'i18n:attributes': {},
},
}
Modified: CMF/branches/2.1/CMFActionIcons/tests/test_exportimport.py
===================================================================
--- CMF/branches/2.1/CMFActionIcons/tests/test_exportimport.py 2007-05-21 17:31:13 UTC (rev 75862)
+++ CMF/branches/2.1/CMFActionIcons/tests/test_exportimport.py 2007-05-21 17:40:54 UTC (rev 75863)
@@ -42,6 +42,13 @@
</action-icons>
"""
+ _EMPTY_I18N_EXPORT = """\
+<?xml version="1.0"?>
+<action-icons xmlns:i18n="http://xml.zope.org/namespaces/i18n"
+ i18n:domain="cmf">
+</action-icons>
+"""
+
_WITH_ICON_EXPORT = """\
<?xml version="1.0"?>
<action-icons>
@@ -60,6 +67,26 @@
ICON_EXPR,
)
+ _WITH_I18N_ICON_EXPORT = """\
+<?xml version="1.0"?>
+<action-icons xmlns:i18n="http://xml.zope.org/namespaces/i18n"
+ i18n:domain="cmf">
+<action-icon
+ category="%s"
+ action_id="%s"
+ title="%s"
+ priority="%d"
+ icon_expr="%s"
+ i18n:attributes="title"
+ />
+</action-icons>
+""" % (CATEGORY,
+ ACTION_ID,
+ TITLE,
+ PRIORITY,
+ ICON_EXPR,
+ )
+
def _initSite(self, with_icon=False):
from OFS.Folder import Folder
from Products.CMFActionIcons.ActionIconsTool import ActionIconsTool
@@ -124,6 +151,13 @@
self.assertEqual(len(ait_info['action_icons']), 0)
+ def test_parseXML_empty_i18n(self):
+ site = self._initSite(with_icon=False)
+ configurator = self._makeOne(site)
+ ait_info = configurator.parseXML(self._EMPTY_I18N_EXPORT)
+
+ self.assertEqual(len(ait_info['action_icons']), 0)
+
def test_parseXML_with_icon(self):
site = self._initSite(with_icon=False)
configurator = self._makeOne(site)
@@ -138,7 +172,21 @@
self.assertEqual(info['priority'], self.PRIORITY)
self.assertEqual(info['icon_expr'], self.ICON_EXPR)
+ def test_parseXML_with_i18n_icon(self):
+ site = self._initSite(with_icon=False)
+ configurator = self._makeOne(site)
+ ait_info = configurator.parseXML(self._WITH_I18N_ICON_EXPORT)
+ self.assertEqual(len(ait_info['action_icons']), 1)
+
+ info = ait_info['action_icons'][0]
+ self.assertEqual(info['category'], self.CATEGORY)
+ self.assertEqual(info['action_id'], self.ACTION_ID)
+ self.assertEqual(info['title'], self.TITLE)
+ self.assertEqual(info['priority'], self.PRIORITY)
+ self.assertEqual(info['icon_expr'], self.ICON_EXPR)
+
+
class Test_exportActionIconsTool(_ActionIconsToolSetup):
layer = ExportImportZCMLLayer
More information about the Checkins
mailing list