[Zope3-checkins] CVS: ZopeProducts/RotterdamSprint - XmlObjectView.py:1.5 configure.zcml:1.12

Joachim Werner joe@iuveno-net.de
Thu, 5 Dec 2002 11:44:30 -0500


Update of /cvs-repository/ZopeProducts/RotterdamSprint
In directory cvs.zope.org:/tmp/cvs-serv27150

Modified Files:
	XmlObjectView.py configure.zcml 
Log Message:
Checking in singleBranchTree.xml

=== ZopeProducts/RotterdamSprint/XmlObjectView.py 1.4 => 1.5 ===
--- ZopeProducts/RotterdamSprint/XmlObjectView.py:1.4	Wed Dec  4 15:43:17 2002
+++ ZopeProducts/RotterdamSprint/XmlObjectView.py	Thu Dec  5 11:44:30 2002
@@ -1,12 +1,14 @@
 from Zope.Publisher.Browser.BrowserView import BrowserView
 from Zope.App.OFS.Container.IContainer import IReadContainer
+from Zope.App.Traversing import objectName, getParents
+
 
 class XmlObjectView(BrowserView):
     """Provide a user interface for editing a contact"""
 
     __used_for__ = IReadContainer
 
-    def children(self):
+    def children_utility(self):
         """Return an XML document that contains the children of an object."""
         result = []
         container = self.context
@@ -16,6 +18,30 @@
                 result.append('<collection name="%s" length="%s" />' % (name, len(item)))
             else:
                 result.append('<item name="%s" />' % name)
+        return ' '.join(result)
+
+        
+    def children(self):
+        """ """
         self.request.response.setHeader('Content-Type', 'text/xml')
-        return u'<?xml version="1.0" ?><children> %s </children>' % ' '.join(result)
+        return u'<?xml version="1.0" ?><children> %s </children>' % self.children_utility()
 
+    def singleBranchTree(self, root=''):
+        """ """
+        result = ''
+        oldItem = self.context
+        for item in getParents(self.context):
+            subItems = []
+            for name in item.keys():
+                subItem = item[name]
+                if IReadContainer.isImplementedBy(subItem):
+                    if oldItem and subItem == oldItem:
+                        subItems.append('<collection name="%s" length="%s">%s</collection>' % (name, len(subItem), result))
+                    else:
+                        subItems.append('<collection name="%s" length="%s" />' % (name, len(subItem)))
+                else:
+                    subItems.append('<item name="%s" />' % name)
+            result = ' '.join(subItems)
+            oldItem = item
+        self.request.response.setHeader('Content-Type', 'text/xml')
+        return u'<?xml version="1.0" ?><children> %s </children>' % result


=== ZopeProducts/RotterdamSprint/configure.zcml 1.11 => 1.12 ===
--- ZopeProducts/RotterdamSprint/configure.zcml:1.11	Wed Dec  4 14:30:45 2002
+++ ZopeProducts/RotterdamSprint/configure.zcml	Thu Dec  5 11:44:30 2002
@@ -31,6 +31,7 @@
     permission="Zope.View"
     factory=".XmlObjectView.">
   <browser:page name="children.xml" attribute="children" />
+  <browser:page name="singleBranchTree.xml" attribute="singleBranchTree" />
 </browser:view>
 
 <!-- below overrides the standard_macros by Rotterdam Skin -->