[Zope3-checkins]
SVN: Zope3/branches/isarsprint-dav-work/src/zope/app/dav/
Update the DAV widgets to also be able to use them as input
widgets. Also
Martijn Pieters
mj at zopatista.com
Thu Oct 14 08:16:32 EDT 2004
Log message for revision 28164:
Update the DAV widgets to also be able to use them as input widgets. Also
clarify the interface for these widgets.
Changed:
U Zope3/branches/isarsprint-dav-work/src/zope/app/dav/interfaces.py
U Zope3/branches/isarsprint-dav-work/src/zope/app/dav/widget.py
-=-
Modified: Zope3/branches/isarsprint-dav-work/src/zope/app/dav/interfaces.py
===================================================================
--- Zope3/branches/isarsprint-dav-work/src/zope/app/dav/interfaces.py 2004-10-14 11:37:10 UTC (rev 28163)
+++ Zope3/branches/isarsprint-dav-work/src/zope/app/dav/interfaces.py 2004-10-14 12:16:31 UTC (rev 28164)
@@ -19,7 +19,7 @@
from zope.interface import Interface
from zope.schema import Text
-from zope.app.form.interfaces import IWidget
+from zope.app.form.interfaces import IInputWidget
class IDAVNamespace(Interface):
@@ -205,10 +205,19 @@
"""Full DAV properties schema"""
-class IDAVWidget(IWidget):
- """A specialized widget used to render DAV properties output."""
+class IDAVWidget(IInputWidget):
+ """A specialized widget used to convert to and from DAV properties."""
+
+ def __call__():
+ """Render the widget."""
+
+ def setRenderedValue(value):
+ """Set the DAV value for the property
+ value can be a DOM Element node representing the value.
+ """
+
class ITextDAVWidget(IDAVWidget):
"""A DAV widget for text values."""
Modified: Zope3/branches/isarsprint-dav-work/src/zope/app/dav/widget.py
===================================================================
--- Zope3/branches/isarsprint-dav-work/src/zope/app/dav/widget.py 2004-10-14 11:37:10 UTC (rev 28163)
+++ Zope3/branches/isarsprint-dav-work/src/zope/app/dav/widget.py 2004-10-14 12:16:31 UTC (rev 28164)
@@ -17,16 +17,16 @@
"""
__docformat__ = 'restructuredtext'
+from xml.dom import minidom
+
from zope.app.dav.interfaces import IDAVWidget
from zope.app.dav.interfaces import ITextDAVWidget
from zope.app.dav.interfaces import ISequenceDAVWidget
-from zope.app.form.interfaces import IWidget
-from zope.app.form import Widget
-from zope.component.interfaces import IViewFactory
+from zope.app.form import InputWidget
from zope.interface import implements
-class DAVWidget(Widget):
+class DAVWidget(InputWidget):
implements(IDAVWidget)
@@ -40,7 +40,18 @@
return str(self._data)
def __call__(self):
- return self.getInputValue()
+ return str(self)
+
+ def setRenderedValue(self, value):
+ if isinstance(value, minidom.Node):
+ text = ''
+ for node in value.childNodes:
+ if node.nodeType != node.TEXT_NODE:
+ continue
+ text += node.nodeValue
+ value = text
+
+ super(DAVWidget, self).setRenderedValue(value)
class TextDAVWidget(DAVWidget):
@@ -52,3 +63,6 @@
def __str__(self):
return u', '.join(self._data)
+
+ def getInputValue(self):
+ return list(self._data).split(',').strip()
More information about the Zope3-Checkins
mailing list