[Zope3-checkins] CVS: Zope3/src/zope/app/browser/form - widget.py:1.29.4.1

Fred L. Drake, Jr. fred@zope.com
Fri, 2 May 2003 12:26:26 -0400


Update of /cvs-repository/Zope3/src/zope/app/browser/form
In directory cvs.zope.org:/tmp/cvs-serv10529

Modified Files:
      Tag: schema-vocabulary-branch
	widget.py 
Log Message:
add redirector magic to support vocabulary-based widgets


=== Zope3/src/zope/app/browser/form/widget.py 1.29 => 1.29.4.1 ===
--- Zope3/src/zope/app/browser/form/widget.py:1.29	Wed Apr 30 19:37:51 2003
+++ Zope3/src/zope/app/browser/form/widget.py	Fri May  2 12:26:25 2003
@@ -28,7 +28,7 @@
 from zope.app.datetimeutils import parseDatetimetz
 from zope.app.datetimeutils import DateTimeError
 from zope.schema.interfaces import ValidationError
-from zope.component import getService
+from zope.component import getService, getView
 
 
 class BrowserWidget(Widget, BrowserView):
@@ -691,6 +691,29 @@
                               id = name,
                               value = value,
                               checked = None) + text
+
+
+# These widget factories delegate to 
+
+def VocabularyFieldDisplayWidget(field, request):
+    """Return a display widget based on a vocabulary field."""
+    view = getView(field.vocabulary, "field-display-widget", request)
+    return view(field)
+
+def VocabularyFieldEditWidget(field, request):
+    """Return a value-selection widget based on a vocabulary field."""
+    view = getView(field.vocabulary, "field-edit-widget", request)
+    return view(field)
+
+def VocabularyMultiFieldDisplayWidget(field, request):
+    """Return a display widget based on a vocabulary field."""
+    view = getView(field.vocabulary, "field-display-multi-widget", request)
+    return view(field)
+
+def VocabularyMultiFieldEditWidget(field, request):
+    """Return a value-selection widget based on a vocabulary field."""
+    view = getView(field.vocabulary, "field-edit-multi-widget", request)
+    return view(field)
 
 
 # XXX Note, some HTML quoting is needed in renderTag and renderElement.