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

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


Log message for revision 90527:
  - 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.4/Products/GenericSetup/CHANGES.txt
  U   Products.GenericSetup/branches/1.4/Products/GenericSetup/tests/test_utils.py
  U   Products.GenericSetup/branches/1.4/Products/GenericSetup/utils.py

-=-
Modified: Products.GenericSetup/branches/1.4/Products/GenericSetup/CHANGES.txt
===================================================================
--- Products.GenericSetup/branches/1.4/Products/GenericSetup/CHANGES.txt	2008-08-28 08:56:03 UTC (rev 90526)
+++ Products.GenericSetup/branches/1.4/Products/GenericSetup/CHANGES.txt	2008-08-28 08:57:32 UTC (rev 90527)
@@ -4,6 +4,10 @@
 GenericSetup 1.4.2 (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.4/Products/GenericSetup/tests/test_utils.py
===================================================================
--- Products.GenericSetup/branches/1.4/Products/GenericSetup/tests/test_utils.py	2008-08-28 08:56:03 UTC (rev 90526)
+++ Products.GenericSetup/branches/1.4/Products/GenericSetup/tests/test_utils.py	2008-08-28 08:57:32 UTC (rev 90527)
@@ -60,7 +60,7 @@
 </dummy>
 """
 
-_NORMAL_PROPERTY_EXPORT = """\
+_NORMAL_PROPERTY_EXPORT = u"""\
 <?xml version="1.0"?>
 <dummy>
  <property name="foo_boolean" type="boolean">True</property>
@@ -70,6 +70,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>
@@ -91,9 +92,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>
@@ -103,6 +104,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>
@@ -122,7 +124,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"?>
@@ -303,7 +305,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')
@@ -328,6 +331,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.4/Products/GenericSetup/utils.py
===================================================================
--- Products.GenericSetup/branches/1.4/Products/GenericSetup/utils.py	2008-08-28 08:56:03 UTC (rev 90526)
+++ Products.GenericSetup/branches/1.4/Products/GenericSetup/utils.py	2008-08-28 08:57:32 UTC (rev 90527)
@@ -660,7 +660,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