[Checkins] SVN: Products.GenericSetup/branches/1.3/Products/GenericSetup/ - Property import/export tests: Fix and test for non-ASCII properties.

Jens Vagelpohl jens at dataflake.org
Thu Aug 28 04:56:04 EDT 2008


Log message for revision 90526:
  - Property import/export tests: Fix and test for non-ASCII properties.
    (https://bugs.launchpad.net/zope-cmf/+bug/202356)
    (https://bugs.launchpad.net/zope-cmf/+bug/242588)
  

Changed:
  U   Products.GenericSetup/branches/1.3/Products/GenericSetup/CHANGES.txt
  U   Products.GenericSetup/branches/1.3/Products/GenericSetup/tests/test_utils.py
  U   Products.GenericSetup/branches/1.3/Products/GenericSetup/utils.py

-=-
Modified: Products.GenericSetup/branches/1.3/Products/GenericSetup/CHANGES.txt
===================================================================
--- Products.GenericSetup/branches/1.3/Products/GenericSetup/CHANGES.txt	2008-08-28 08:54:09 UTC (rev 90525)
+++ Products.GenericSetup/branches/1.3/Products/GenericSetup/CHANGES.txt	2008-08-28 08:56:03 UTC (rev 90526)
@@ -2,6 +2,10 @@
 
   GenericSetup 1.3.4 (unreleased)
 
+    - Property import/export tests: Fix and test for non-ASCII properties.
+      (https://bugs.launchpad.net/zope-cmf/+bug/202356)
+      (https://bugs.launchpad.net/zope-cmf/+bug/242588)
+
     - Provide default for dependencies when processing metadata.xml, to
       avoid a KeyError.
       (https://bugs.launchpad.net/zope-cmf/+bug/255301)

Modified: Products.GenericSetup/branches/1.3/Products/GenericSetup/tests/test_utils.py
===================================================================
--- Products.GenericSetup/branches/1.3/Products/GenericSetup/tests/test_utils.py	2008-08-28 08:54:09 UTC (rev 90525)
+++ Products.GenericSetup/branches/1.3/Products/GenericSetup/tests/test_utils.py	2008-08-28 08:56:03 UTC (rev 90526)
@@ -47,7 +47,7 @@
 </dummy>
 """
 
-_NORMAL_PROPERTY_EXPORT = """\
+_NORMAL_PROPERTY_EXPORT = u"""\
 <?xml version="1.0"?>
 <dummy>
  <property name="foo_boolean" type="boolean">True</property>
@@ -57,6 +57,7 @@
  <property name="foo_lines" type="lines">
   <element value="Foo"/>
   <element value="Lines"/>
+  <element value="\xfcbrigens"/>
  </property>
  <property name="foo_long" type="long">1</property>
  <property name="foo_string" type="string">Foo String</property>
@@ -78,9 +79,9 @@
  <property name="foo_float_nodel">3.1415</property>
  <property name="foo_boolean_nodel">True</property>
 </dummy>
-"""
+""".encode('utf-8')
 
-_FIXED_PROPERTY_EXPORT = """\
+_FIXED_PROPERTY_EXPORT = u"""\
 <?xml version="1.0"?>
 <dummy>
  <property name="foo_boolean">True</property>
@@ -90,6 +91,7 @@
  <property name="foo_lines">
   <element value="Foo"/>
   <element value="Lines"/>
+ <element value="\xfcbrigens"/>
  </property>
  <property name="foo_long">1</property>
  <property name="foo_string">Foo String</property>
@@ -109,7 +111,7 @@
  <property name="foo_float_nodel">3.1415</property>
  <property name="foo_boolean_nodel">True</property>
 </dummy>
-"""
+""".encode('utf-8')
 
 _SPECIAL_IMPORT = """\
 <?xml version="1.0"?>
@@ -274,7 +276,8 @@
         obj._updateProperty('foo_date', '2000/01/01')
         obj._updateProperty('foo_float', '1.1')
         obj._updateProperty('foo_int', '1')
-        obj._updateProperty('foo_lines', 'Foo\nLines')
+        obj._updateProperty('foo_lines', 
+                u'Foo\nLines\n\xfcbrigens'.encode('utf-8'))
         obj._updateProperty('foo_long', '1')
         obj._updateProperty('foo_string', 'Foo String')
         obj._updateProperty('foo_text', 'Foo\nText')
@@ -299,6 +302,12 @@
         self._populate(self.helpers.context)
         doc = self.helpers._doc = PrettyDocument()
         node = doc.createElement('dummy')
+
+        # The extraction process wants to decode text properties
+        # to unicode using the default ZPublisher encoding, which
+        # defaults to iso-8859-15. We force UTF-8 here because we 
+        # forced our properties to be UTF-8 encoded.
+        self.helpers._encoding = 'utf-8'
         node.appendChild(self.helpers._extractProperties())
         doc.appendChild(node)
 

Modified: Products.GenericSetup/branches/1.3/Products/GenericSetup/utils.py
===================================================================
--- Products.GenericSetup/branches/1.3/Products/GenericSetup/utils.py	2008-08-28 08:54:09 UTC (rev 90525)
+++ Products.GenericSetup/branches/1.3/Products/GenericSetup/utils.py	2008-08-28 08:56:03 UTC (rev 90526)
@@ -658,7 +658,7 @@
             if isinstance(prop, (tuple, list)):
                 for value in prop:
                     if isinstance(value, str):
-                        value.decode(self._encoding)
+                        value = value.decode(self._encoding)
                     child = self._doc.createElement('element')
                     child.setAttribute('value', value)
                     node.appendChild(child)



More information about the Checkins mailing list