[Zope3-checkins] SVN: Zope3/branches/ZopeX3-3.0/ Fixed issue 333: XML Tree doesn't load if some item contains

Dmitry Vasiliev dima at hlabs.spb.ru
Thu May 5 02:17:45 EDT 2005


Log message for revision 30240:
  Fixed issue 333: XML Tree doesn't load if some item contains
  non-ASCII characters.
  

Changed:
  U   Zope3/branches/ZopeX3-3.0/doc/CHANGES.txt
  U   Zope3/branches/ZopeX3-3.0/src/zope/app/rotterdam/tests/output/test1.xml
  U   Zope3/branches/ZopeX3-3.0/src/zope/app/rotterdam/tests/output/test4.xml
  U   Zope3/branches/ZopeX3-3.0/src/zope/app/rotterdam/tests/output/test5.xml
  U   Zope3/branches/ZopeX3-3.0/src/zope/app/rotterdam/tests/test_xmlnavigationviews.py
  U   Zope3/branches/ZopeX3-3.0/src/zope/app/rotterdam/tests/util.py
  U   Zope3/branches/ZopeX3-3.0/src/zope/app/rotterdam/xmlobject.py
  U   Zope3/branches/ZopeX3-3.0/src/zope/app/site/tests/placefulsetup.py
  U   Zope3/branches/ZopeX3-3.0/src/zope/app/tests/setup.py

-=-
Modified: Zope3/branches/ZopeX3-3.0/doc/CHANGES.txt
===================================================================
--- Zope3/branches/ZopeX3-3.0/doc/CHANGES.txt	2005-05-04 14:12:06 UTC (rev 30239)
+++ Zope3/branches/ZopeX3-3.0/doc/CHANGES.txt	2005-05-05 06:17:45 UTC (rev 30240)
@@ -10,6 +10,9 @@
 
     Bug Fixes
 
+      - Fixed issue 333 (XML Tree doesn't load if some item
+        contains non-ASCII characters).
+
       - Fixed issue 314 (i18n:translate removes line breaks
         from <pre>...</pre> contents).
 

Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/rotterdam/tests/output/test1.xml
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/rotterdam/tests/output/test1.xml	2005-05-04 14:12:06 UTC (rev 30239)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/rotterdam/tests/output/test1.xml	2005-05-05 06:17:45 UTC (rev 30240)
@@ -1 +1 @@
-<?xml version="1.0" ?><children><collection name="" length="2" icon_url="" isroot=""><collection name="folder1" length="2" icon_url=""></collection><collection name="folder2" length="1" icon_url=""/><collection name="++etc++site" length="1" icon_url=""/></collection></children>
+<?xml version="1.0" ?><children><collection name="" length="3" icon_url="" isroot=""><collection name="folder1" length="2" icon_url=""></collection><collection name="folder2" length="1" icon_url=""/><collection name="папка3" length="1" icon_url=""/><collection name="++etc++site" length="1" icon_url=""/></collection></children>

Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/rotterdam/tests/output/test4.xml
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/rotterdam/tests/output/test4.xml	2005-05-04 14:12:06 UTC (rev 30239)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/rotterdam/tests/output/test4.xml	2005-05-05 06:17:45 UTC (rev 30240)
@@ -1 +1 @@
-<?xml version="1.0" ?><children><collection name="folder1" length="2" icon_url=""/><collection name="folder2" length="1" icon_url=""/><collection name="++etc++site" length="1" icon_url=""/></children>
+<?xml version="1.0" ?><children><collection name="folder1" length="2" icon_url=""/><collection name="folder2" length="1" icon_url=""/><collection name="папка3" length="1" icon_url=""/><collection name="++etc++site" length="1" icon_url=""/></children>

Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/rotterdam/tests/output/test5.xml
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/rotterdam/tests/output/test5.xml	2005-05-04 14:12:06 UTC (rev 30239)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/rotterdam/tests/output/test5.xml	2005-05-05 06:17:45 UTC (rev 30240)
@@ -1 +1 @@
-<?xml version="1.0" ?><children><collection name="" length="2" icon_url="" isroot=""><collection name="folder1" length="2" icon_url=""><collection name="folder1_1" length="2" icon_url=""><collection name="folder1_1_1" length="1" icon_url=""></collection><collection name="folder1_1_2" length="0" icon_url=""/><item name="++etc++site" /></collection><collection name="folder1_2" length="1" icon_url=""/><item name="++etc++site" /></collection><collection name="folder2" length="1" icon_url=""/><collection name="++etc++site" length="1" icon_url=""/></collection></children>
+<?xml version="1.0" ?><children><collection name="" length="3" icon_url="" isroot=""><collection name="folder1" length="2" icon_url=""><collection name="folder1_1" length="2" icon_url=""><collection name="folder1_1_1" length="1" icon_url=""></collection><collection name="folder1_1_2" length="0" icon_url=""/><item name="++etc++site" /></collection><collection name="folder1_2" length="1" icon_url=""/><item name="++etc++site" /></collection><collection name="folder2" length="1" icon_url=""/><collection name="папка3" length="1" icon_url=""/><collection name="++etc++site" length="1" icon_url=""/></collection></children>

Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/rotterdam/tests/test_xmlnavigationviews.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/rotterdam/tests/test_xmlnavigationviews.py	2005-05-04 14:12:06 UTC (rev 30239)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/rotterdam/tests/test_xmlnavigationviews.py	2005-05-05 06:17:45 UTC (rev 30240)
@@ -36,7 +36,7 @@
     pass
 
 class TestXmlObject(PlacefulSetup, TestCase):
-    
+
     def setUp(self):
         PlacefulSetup.setUp(self, site=True)
         self.createStandardServices()
@@ -51,7 +51,7 @@
 
         treeView = rcxov(self.folder1_1_1, TestRequest()).children
         check_xml(treeView(), util.read_output('test3.xml'))
-        
+
         treeView = rcxov(self.rootFolder, TestRequest()).children
         check_xml(treeView(), util.read_output('test4.xml'))
 
@@ -68,7 +68,7 @@
                 raise NotFoundError(self, name, request)
             def __call__(self):
                 return self.singleBranchTree()
-            
+
         ztapi.browserView(IReadContainer, 'singleBranchTree.xml',
                           ReadContainerView)
 

Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/rotterdam/tests/util.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/rotterdam/tests/util.py	2005-05-04 14:12:06 UTC (rev 30239)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/rotterdam/tests/util.py	2005-05-05 06:17:45 UTC (rev 30240)
@@ -24,8 +24,8 @@
 
 def read_input(filename):
     filename = os.path.join(input_dir, filename)
-    return open(filename, 'r').read()
+    return open(filename, 'r').read().decode("utf-8")
 
 def read_output(filename):
     filename = os.path.join(output_dir, filename)
-    return open(filename, 'r').read()
+    return open(filename, 'r').read().decode("utf-8")

Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/rotterdam/xmlobject.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/rotterdam/xmlobject.py	2005-05-04 14:12:06 UTC (rev 30239)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/rotterdam/xmlobject.py	2005-05-05 06:17:45 UTC (rev 30240)
@@ -31,16 +31,16 @@
     response.setHeader('Expires', formatdate(time.time()-7*86400))#7 days ago
 
 def xmlEscape(format, *args):
-    quotedArgs = [ quoteattr(str(arg)) for arg in args ]
-    return format%tuple(quotedArgs)
-        
+    quotedArgs = [quoteattr(unicode(arg)) for arg in args]
+    return format % tuple(quotedArgs)
+
 def xmlEscapeWithCData(format, *args):
     cData = args[-1]
-    quotedArgs = [ quoteattr(str(arg)) for arg in args[:-1] ]
+    quotedArgs = [quoteattr(unicode(arg)) for arg in args[:-1]]
     quotedArgsWithCData = quotedArgs + [cData]
-    return format%tuple(quotedArgsWithCData)
-        
+    return format % tuple(quotedArgsWithCData)
 
+
 class ReadContainerXmlObjectView(BrowserView):
     """Provide a xml interface for dynamic navigation tree in UI"""
 
@@ -61,7 +61,7 @@
         keys = list(container.keys())
 
         # include the service manager
-        keys.append('++etc++site')
+        keys.append(u'++etc++site')
 
         for name in keys:
 
@@ -73,14 +73,14 @@
             iconUrl = self.getIconUrl(item)
             if IReadContainer.providedBy(item):
                 result.append(xmlEscape(
-                    '<collection name=%s length=%s icon_url=%s/>',
+                    u'<collection name=%s length=%s icon_url=%s/>',
                     name, len(item), iconUrl))
             else:
                 result.append(xmlEscape(
-                    '<item name=%s icon_url=%s/>',
+                    u'<item name=%s icon_url=%s/>',
                     name, iconUrl))
 
-        return ' '.join(result)
+        return u' '.join(result)
 
 
     def children(self):
@@ -113,7 +113,7 @@
                 keys = []
 
             # include the service manager
-            keys.append('++etc++site')
+            keys.append(u'++etc++site')
 
             for name in keys:
                 # Only include items we can traverse to
@@ -123,30 +123,29 @@
                     # the test below seems to be browken with the ++etc++site case
                     if subItem == oldItem:
                         subItems.append(xmlEscapeWithCData(
-                            '<collection name=%s length=%s '
-                            'icon_url=%s>%s</collection>', 
+                            u'<collection name=%s length=%s '
+                            u'icon_url=%s>%s</collection>', 
                             name, len(subItem), iconUrl, result))
                     else:
                         subItems.append(xmlEscape(
-                            '<collection name=%s length=%s '
-                            'icon_url=%s/>',
+                            u'<collection name=%s length=%s '
+                            u'icon_url=%s/>',
                             name, len(subItem), iconUrl))
                 else:
-                    subItems.append(xmlEscape('<item name=%s />', name))
+                    subItems.append(xmlEscape(u'<item name=%s />', name))
 
             result = ' '.join(subItems)
             oldItem = item
 
         # do not forget root folder
         iconUrl = self.getIconUrl(oldItem)
-        result = (xmlEscapeWithCData('<collection name="" length=%s '
-                  'icon_url=%s isroot="">%s</collection>',
+        result = (xmlEscapeWithCData(u'<collection name="" length=%s '
+                  u'icon_url=%s isroot="">%s</collection>',
                   len(oldItem), iconUrl, result))
 
         self.request.response.setHeader('Content-Type', 'text/xml')
         setNoCacheHeaders(self.request.response)
-        res= u'<?xml version="1.0" ?><children> %s </children>' % result
-        return res
+        return u'<?xml version="1.0" ?><children> %s </children>' % result
 
 class XmlObjectView(BrowserView):
     """Provide a xml interface for dynamic navigation tree in UI"""

Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/site/tests/placefulsetup.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/site/tests/placefulsetup.py	2005-05-04 14:12:06 UTC (rev 30239)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/site/tests/placefulsetup.py	2005-05-05 06:17:45 UTC (rev 30240)
@@ -40,19 +40,34 @@
 class PlacefulSetup(PlacelessSetup):
 
     # Places :)
-    rootFolder  = Place('')
+    rootFolder  = Place(u'')
 
-    folder1     = Place('folder1')
-    folder1_1   = Place('folder1/folder1_1')
-    folder1_1_1 = Place('folder1/folder1_1/folder1_1_1')
-    folder1_1_2 = Place('folder1/folder1_2/folder1_1_2')
-    folder1_2   = Place('folder1/folder1_2')
-    folder1_2_1 = Place('folder1/folder1_2/folder1_2_1')
+    folder1     = Place(u'folder1')
+    folder1_1   = Place(u'folder1/folder1_1')
+    folder1_1_1 = Place(u'folder1/folder1_1/folder1_1_1')
+    folder1_1_2 = Place(u'folder1/folder1_2/folder1_1_2')
+    folder1_2   = Place(u'folder1/folder1_2')
+    folder1_2_1 = Place(u'folder1/folder1_2/folder1_2_1')
 
-    folder2     = Place('folder2')
-    folder2_1   = Place('folder2/folder2_1')
-    folder2_1_1 = Place('folder2/folder2_1/folder2_1_1')
+    folder2     = Place(u'folder2')
+    folder2_1   = Place(u'folder2/folder2_1')
+    folder2_1_1 = Place(u'folder2/folder2_1/folder2_1_1')
 
+    folder3     = Place(u"\N{CYRILLIC SMALL LETTER PE}"
+                        u"\N{CYRILLIC SMALL LETTER A}"
+                        u"\N{CYRILLIC SMALL LETTER PE}"
+                        u"\N{CYRILLIC SMALL LETTER KA}"
+                        u"\N{CYRILLIC SMALL LETTER A}3")
+    folder3_1   = Place(u"\N{CYRILLIC SMALL LETTER PE}"
+                        u"\N{CYRILLIC SMALL LETTER A}"
+                        u"\N{CYRILLIC SMALL LETTER PE}"
+                        u"\N{CYRILLIC SMALL LETTER KA}"
+                        u"\N{CYRILLIC SMALL LETTER A}3/"
+                        u"\N{CYRILLIC SMALL LETTER PE}"
+                        u"\N{CYRILLIC SMALL LETTER A}"
+                        u"\N{CYRILLIC SMALL LETTER PE}"
+                        u"\N{CYRILLIC SMALL LETTER KA}"
+                        u"\N{CYRILLIC SMALL LETTER A}3_1")
 
     def setUp(self, folders=False, site=False):
         setup.placefulSetUp()

Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/tests/setup.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/tests/setup.py	2005-05-04 14:12:06 UTC (rev 30239)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/tests/setup.py	2005-05-05 06:17:45 UTC (rev 30240)
@@ -119,24 +119,39 @@
 def buildSampleFolderTree():
     # set up a reasonably complex folder structure
     #
-    #     ____________ rootFolder ____________
-    #    /                                    \
-    # folder1 __________________            folder2
-    #   |                       \             |
-    # folder1_1 ____           folder1_2    folder2_1
+    #     ____________ rootFolder ______________________________
+    #    /                                    \                 \
+    # folder1 __________________            folder2           folder3
+    #   |                       \             |                 |
+    # folder1_1 ____           folder1_2    folder2_1         folder3_1
     #   |           \            |            |
     # folder1_1_1 folder1_1_2  folder1_2_1  folder2_1_1
 
     root = rootFolder()
-    root['folder1'] = Folder()
-    root['folder1']['folder1_1'] = Folder()
-    root['folder1']['folder1_1']['folder1_1_1'] = Folder()
-    root['folder1']['folder1_1']['folder1_1_2'] = Folder()
-    root['folder1']['folder1_2'] = Folder()
-    root['folder1']['folder1_2']['folder1_2_1'] = Folder()
-    root['folder2'] = Folder()
-    root['folder2']['folder2_1'] = Folder()
-    root['folder2']['folder2_1']['folder2_1_1'] = Folder()
+    root[u'folder1'] = Folder()
+    root[u'folder1'][u'folder1_1'] = Folder()
+    root[u'folder1'][u'folder1_1'][u'folder1_1_1'] = Folder()
+    root[u'folder1'][u'folder1_1'][u'folder1_1_2'] = Folder()
+    root[u'folder1'][u'folder1_2'] = Folder()
+    root[u'folder1'][u'folder1_2'][u'folder1_2_1'] = Folder()
+    root[u'folder2'] = Folder()
+    root[u'folder2'][u'folder2_1'] = Folder()
+    root[u'folder2'][u'folder2_1'][u'folder2_1_1'] = Folder()
+    root[u"\N{CYRILLIC SMALL LETTER PE}"
+         u"\N{CYRILLIC SMALL LETTER A}"
+         u"\N{CYRILLIC SMALL LETTER PE}"
+         u"\N{CYRILLIC SMALL LETTER KA}"
+         u"\N{CYRILLIC SMALL LETTER A}3"] = Folder()
+    root[u"\N{CYRILLIC SMALL LETTER PE}"
+         u"\N{CYRILLIC SMALL LETTER A}"
+         u"\N{CYRILLIC SMALL LETTER PE}"
+         u"\N{CYRILLIC SMALL LETTER KA}"
+         u"\N{CYRILLIC SMALL LETTER A}3"][
+         u"\N{CYRILLIC SMALL LETTER PE}"
+         u"\N{CYRILLIC SMALL LETTER A}"
+         u"\N{CYRILLIC SMALL LETTER PE}"
+         u"\N{CYRILLIC SMALL LETTER KA}"
+         u"\N{CYRILLIC SMALL LETTER A}3_1"] = Folder()
 
     return root
 
@@ -173,7 +188,7 @@
 
     This utility is useful for tests that need to set up utilities.
     """
-    
+
     folder_name = (name or (iface.__name__ + 'Utility')) + suffix
     default = zapi.traverse(servicemanager, 'default')
     default[folder_name] = utility



More information about the Zope3-Checkins mailing list