[Zope3-checkins]
SVN: Zope3/branches/philikon-widget-subdirective/src/zope/app/form/
Introduce marker interfaces for marking widget classes according
Philipp von Weitershausen
philikon at philikon.de
Sun Jun 12 10:12:11 EDT 2005
Log message for revision 30760:
Introduce marker interfaces for marking widget classes according
to their factory signature (arguments to __init__).
Changed:
U Zope3/branches/philikon-widget-subdirective/src/zope/app/form/browser/__init__.py
U Zope3/branches/philikon-widget-subdirective/src/zope/app/form/interfaces.py
-=-
Modified: Zope3/branches/philikon-widget-subdirective/src/zope/app/form/browser/__init__.py
===================================================================
--- Zope3/branches/philikon-widget-subdirective/src/zope/app/form/browser/__init__.py 2005-06-12 14:06:03 UTC (rev 30759)
+++ Zope3/branches/philikon-widget-subdirective/src/zope/app/form/browser/__init__.py 2005-06-12 14:12:10 UTC (rev 30760)
@@ -72,3 +72,19 @@
from zope.app.form.browser.sequencewidget import SequenceDisplayWidget
from zope.app.form.browser.objectwidget import ObjectWidget
+
+# mark items and sequence widgets with the correct factory interfaces
+from zope.interface import directlyProvides
+from zope.app.form.interfaces import IVocabularyWidgetFactory
+from zope.app.form.interfaces import ISequenceWidgetFactory
+
+for widget_class in (ItemDisplayWidget, ItemsMultiDisplayWidget,
+ SetDisplayWidget, ListDisplayWidget, SelectWidget,
+ DropdownWidget, RadioWidget, MultiSelectWidget,
+ MultiSelectSetWidget, MultiCheckBoxWidget,
+ OrderedMultiSelectWidget):
+ directlyProvides(widget_class, IVocabularyWidgetFactory)
+
+for widget_class in (SequenceWidget, TupleSequenceWidget,
+ ListSequenceWidget, SequenceDisplayWidget):
+ directlyProvides(widget_class, ISequenceWidgetFactory)
Modified: Zope3/branches/philikon-widget-subdirective/src/zope/app/form/interfaces.py
===================================================================
--- Zope3/branches/philikon-widget-subdirective/src/zope/app/form/interfaces.py 2005-06-12 14:06:03 UTC (rev 30759)
+++ Zope3/branches/philikon-widget-subdirective/src/zope/app/form/interfaces.py 2005-06-12 14:12:10 UTC (rev 30760)
@@ -18,7 +18,7 @@
__docformat__ = 'restructuredtext'
from zope.schema.interfaces import ValidationError
-from zope.component.interfaces import IView
+from zope.component.interfaces import IView, IViewFactory
from zope.interface import Attribute, Interface, implements
from zope.schema import Bool
from zope.app.exception.interfaces import UserError
@@ -154,6 +154,28 @@
used for the form key.
"""
+class IWidgetFactory(IViewFactory):
+ """Create a widget."""
+
+class ISequenceWidgetFactory(IWidgetFactory):
+ """Create a sequence widget.
+
+ A widget factory should provide this interface to indicate that
+ its call signature is different from other widget factories."""
+
+ def __call__(context, field, request):
+ """Creates a sequence widget with ``field`` being the list element
+ field type."""
+
+class IVocabularyWidgetFactory(IWidgetFactory):
+ """Create a vocabulary widget.
+
+ A widget factory should provide this interface to indicate that
+ its call signature is different from other widget factories."""
+
+ def __call__(field, vocabulary, request):
+ """Creates a vocabulary widget."""
+
class IInputWidget(IWidget):
"""A widget for editing a field value."""
More information about the Zope3-Checkins
mailing list