[CMF-checkins] SVN: CMF/trunk/ - made sure imported settings are not unicode

Yvo Schubbe y.2005- at wcm-solutions.de
Tue Nov 8 13:45:42 EST 2005


Log message for revision 39983:
  - made sure imported settings are not unicode

Changed:
  U   CMF/trunk/CMFCore/exportimport/tests/test_actions.py
  U   CMF/trunk/CMFCore/exportimport/tests/test_typeinfo.py
  U   CMF/trunk/GenericSetup/MailHost/exportimport.py
  U   CMF/trunk/GenericSetup/MailHost/tests/test_exportimport.py
  U   CMF/trunk/GenericSetup/PluginIndexes/exportimport.py
  U   CMF/trunk/GenericSetup/ZCTextIndex/exportimport.py
  U   CMF/trunk/GenericSetup/testing.py

-=-
Modified: CMF/trunk/CMFCore/exportimport/tests/test_actions.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/tests/test_actions.py	2005-11-08 16:33:53 UTC (rev 39982)
+++ CMF/trunk/CMFCore/exportimport/tests/test_actions.py	2005-11-08 18:45:42 UTC (rev 39983)
@@ -84,6 +84,22 @@
         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)
+
     def setUp(self):
         from Products.CMFCore.ActionInformation import Action
         import Products.CMFCore.exportimport
@@ -111,6 +127,10 @@
 
         obj._setObject('foo_action', Action('foo_action'))
 
+    def _verifyImport(self, obj):
+        self.assertEqual(type(obj.title), str)
+        self.assertEqual(obj.title, '')
+
     def setUp(self):
         from Products.CMFCore.ActionInformation import ActionCategory
         import Products.CMFCore.exportimport
@@ -142,6 +162,12 @@
         obj.foo_category._setObject('foo_action', Action('foo_action'))
         obj.foo_category.foo_action.i18n_domain = 'foo_domain'
 
+    def _verifyImport(self, obj):
+        self.assertEqual(type(obj.action_providers), tuple)
+        self.assertEqual(obj.action_providers, ('portal_actions',))
+        self.assertEqual(type(obj.action_providers[0]), str)
+        self.assertEqual(obj.action_providers[0], 'portal_actions')
+
     def setUp(self):
         from Products.CMFCore.ActionsTool import ActionsTool
         import Products.CMFCore.exportimport

Modified: CMF/trunk/CMFCore/exportimport/tests/test_typeinfo.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/tests/test_typeinfo.py	2005-11-08 16:33:53 UTC (rev 39982)
+++ CMF/trunk/CMFCore/exportimport/tests/test_typeinfo.py	2005-11-08 18:45:42 UTC (rev 39983)
@@ -55,6 +55,27 @@
 
         return TypeInformationNodeAdapter
 
+    def _populate(self, obj):
+        obj.addAction('foo_action', 'Foo', 'string:${object_url}/foo',
+                      'python:1', (), 'Bar')
+
+    def _verifyImport(self, obj):
+        self.assertEqual(type(obj._aliases), dict)
+        self.assertEqual(obj._aliases, {'(Default)': 'foo', 'view': 'foo'})
+        self.assertEqual(type(obj._aliases['view']), str)
+        self.assertEqual(obj._aliases['view'], 'foo')
+        self.assertEqual(type(obj._actions), tuple)
+        self.assertEqual(type(obj._actions[0].id), str)
+        self.assertEqual(obj._actions[0].id, 'foo_action')
+        self.assertEqual(type(obj._actions[0].title), str)
+        self.assertEqual(obj._actions[0].title, 'Foo')
+        self.assertEqual(type(obj._actions[0].description), str)
+        self.assertEqual(obj._actions[0].description, '')
+        self.assertEqual(type(obj._actions[0].category), str)
+        self.assertEqual(obj._actions[0].category, 'Bar')
+        self.assertEqual(type(obj._actions[0].condition.text), str)
+        self.assertEqual(obj._actions[0].condition.text, 'python:1')
+
     def setUp(self):
         from Products.CMFCore.TypesTool import FactoryTypeInformation
         import Products.CMFCore.exportimport
@@ -68,11 +89,7 @@
         self._obj = FactoryTypeInformation('foo_fti')
         self._XML = _FTI_XML
 
-    def _populate(self, obj):
-        obj.addAction('foo_action', 'Foo', 'string:${object_url}/foo',
-                      'python:1', (), 'Bar')
 
-
 def test_suite():
     return unittest.TestSuite((
         unittest.makeSuite(TypeInformationNodeAdapterTests),

Modified: CMF/trunk/GenericSetup/MailHost/exportimport.py
===================================================================
--- CMF/trunk/GenericSetup/MailHost/exportimport.py	2005-11-08 16:33:53 UTC (rev 39982)
+++ CMF/trunk/GenericSetup/MailHost/exportimport.py	2005-11-08 18:45:42 UTC (rev 39983)
@@ -44,5 +44,5 @@
         """
         self.context.smtp_host = str(node.getAttribute('smtp_host'))
         self.context.smtp_port = int(node.getAttribute('smtp_port'))
-        self.context.smtp_uid = node.getAttribute('smtp_uid')
-        self.context.smtp_pwd = node.getAttribute('smtp_pwd')
+        self.context.smtp_uid = node.getAttribute('smtp_uid').encode('utf-8')
+        self.context.smtp_pwd = node.getAttribute('smtp_pwd').encode('utf-8')

Modified: CMF/trunk/GenericSetup/MailHost/tests/test_exportimport.py
===================================================================
--- CMF/trunk/GenericSetup/MailHost/tests/test_exportimport.py	2005-11-08 16:33:53 UTC (rev 39982)
+++ CMF/trunk/GenericSetup/MailHost/tests/test_exportimport.py	2005-11-08 18:45:42 UTC (rev 39983)
@@ -35,6 +35,16 @@
 
         return MailHostNodeAdapter
 
+    def _verifyImport(self, obj):
+        self.assertEqual(type(obj.smtp_host), str)
+        self.assertEqual(obj.smtp_host, 'localhost')
+        self.assertEqual(type(obj.smtp_port), int)
+        self.assertEqual(obj.smtp_port, 25)
+        self.assertEqual(type(obj.smtp_pwd), str)
+        self.assertEqual(obj.smtp_pwd, '')
+        self.assertEqual(type(obj.smtp_uid), str)
+        self.assertEqual(obj.smtp_uid, '')
+
     def setUp(self):
         import Products.Five
         from Products.Five import zcml

Modified: CMF/trunk/GenericSetup/PluginIndexes/exportimport.py
===================================================================
--- CMF/trunk/GenericSetup/PluginIndexes/exportimport.py	2005-11-08 16:33:53 UTC (rev 39982)
+++ CMF/trunk/GenericSetup/PluginIndexes/exportimport.py	2005-11-08 18:45:42 UTC (rev 39983)
@@ -55,7 +55,8 @@
         indexed_attrs = []
         for child in node.childNodes:
             if child.nodeName == 'indexed_attr':
-                indexed_attrs.append(child.getAttribute('value'))
+                indexed_attrs.append(
+                                  child.getAttribute('value').encode('utf-8'))
         self.context.indexed_attrs = indexed_attrs
         self.context.clear()
 
@@ -104,8 +105,8 @@
     def importNode(self, node, mode=PURGE):
         """Import the object from the DOM node.
         """
-        self.context._edit(node.getAttribute('since_field'),
-                           node.getAttribute('until_field'))
+        self.context._edit(node.getAttribute('since_field').encode('utf-8'),
+                           node.getAttribute('until_field').encode('utf-8'))
         self.context.clear()
 
 
@@ -173,7 +174,8 @@
     def importNode(self, node, mode=PURGE):
         """Import the object from the DOM node.
         """
-        self.context.setExpression(node.getAttribute('expression'))
+        self.context.setExpression(
+                              node.getAttribute('expression').encode('utf-8'))
         self.context.clear()
 
 

Modified: CMF/trunk/GenericSetup/ZCTextIndex/exportimport.py
===================================================================
--- CMF/trunk/GenericSetup/ZCTextIndex/exportimport.py	2005-11-08 16:33:53 UTC (rev 39982)
+++ CMF/trunk/GenericSetup/ZCTextIndex/exportimport.py	2005-11-08 18:45:42 UTC (rev 39983)
@@ -54,7 +54,8 @@
         for child in node.childNodes:
             if child.nodeName == 'element':
                 element = element_factory.instantiate(
-                      child.getAttribute('group'), child.getAttribute('name'))
+                      child.getAttribute('group').encode('utf-8'),
+                      child.getAttribute('name').encode('utf-8'))
                 pipeline.append(element)
         self.context._pipeline = tuple(pipeline)
         #clear lexicon
@@ -105,6 +106,7 @@
         indexed_attrs = []
         for child in node.childNodes:
             if child.nodeName == 'indexed_attr':
-                indexed_attrs.append(child.getAttribute('value'))
+                indexed_attrs.append(
+                                  child.getAttribute('value').encode('utf-8'))
         self.context.indexed_attrs = indexed_attrs
         self.context.clear()

Modified: CMF/trunk/GenericSetup/testing.py
===================================================================
--- CMF/trunk/GenericSetup/testing.py	2005-11-08 16:33:53 UTC (rev 39982)
+++ CMF/trunk/GenericSetup/testing.py	2005-11-08 18:45:42 UTC (rev 39983)
@@ -35,6 +35,9 @@
     def _populate(self, obj):
         pass
 
+    def _verifyImport(self, obj):
+        pass
+
     def test_z3interfaces(self):
         verifyClass(INodeExporter, self._getTargetClass())
         verifyClass(INodeImporter, self._getTargetClass())
@@ -47,5 +50,6 @@
     def test_importNode(self):
         node = parseString(self._XML).documentElement
         self.assertEqual(INodeImporter(self._obj).importNode(node), None)
+        self._verifyImport(self._obj)
         node = INodeExporter(self._obj).exportNode(PrettyDocument())
         self.assertEqual(node.toprettyxml(' '), self._XML)



More information about the CMF-checkins mailing list