[Zope-CVS] CVS: ZopeProducts/RotterdamSprint - XmlObjectView.py:1.1 configure.zcml:1.5

Joachim Werner joe@iuveno-net.de
Wed, 4 Dec 2002 04:44:14 -0500


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

Modified Files:
	configure.zcml 
Added Files:
	XmlObjectView.py 
Log Message:
First Checkin of XmlObjectView. Returns XML-formatted information about contents of container objects for use in UIs.

=== Added File ZopeProducts/RotterdamSprint/XmlObjectView.py ===
from Zope.Publisher.Browser.BrowserView import BrowserView
from Zope.App.OFS.Container.IContainer import IReadContainer

class XmlObjectView(BrowserView):
    """Provide a user interface for editing a contact"""

    __used_for__ = IReadContainer

    def children(self):
        """Return an XML document that contains the children of an object."""
        result = []
        container = self.context
        for name in container.keys():
            item = container[name]
            if IReadContainer.isImplementedBy(item):
                result.append('<collection name="%s" length="%s" />' % (name, len(item)))
            else:
                result.append('<item name="%s" />' % name)
        return '<children> %s </children>' % ' '.join(result)



=== ZopeProducts/RotterdamSprint/configure.zcml 1.4 => 1.5 ===
--- ZopeProducts/RotterdamSprint/configure.zcml:1.4	Wed Dec  4 04:25:36 2002
+++ ZopeProducts/RotterdamSprint/configure.zcml	Wed Dec  4 04:44:14 2002
@@ -14,5 +14,12 @@
     permission="Zope.View"
     template="template.pt"
     layer="rotterdam" />
+
+  <browser:view
+   for="Zope.App.OFS.Container.IContainer.IReadContainer"
+   permission="Zope.View"
+   factory=".XmlObjectView.">
+   <browser:page name="children.xml" attribute="children" />
+  </browser:view>
 
 </zopeConfigure>