[Zope3-dev] RFC: CustomWidgetFactory and widgets having
different __init__ signature
Adam Groszer
adamg at fw.hu
Thu Nov 17 10:20:20 EST 2005
Hello Dominik,
Your solution looks good.
I would propose, that we still mark the widgets with different
__init__ signatures with something to be able to wrap them into
different factories in metaconfigure.py to make like a bit easier.
What I have in mind:
itemswidgets.py:
class ItemsWidgetBase(TranslationHook, SimpleInputWidget):
"""Convenience base class for widgets displaying items/choices."""
implements(IMultiWidgetMarker)
metaconfigure.py:
if IMultiWidgetMarker.implementedBy(class_):
wrapped = CustomSequenceWidgetFactory(class_)
#and so on with the different signatures
else:
wrapped = CustomWidgetFactory(class_)
self._widgets[field+'_widget'] = wrapped
DH> Are you fixing issue 451? Otherwise, I could do it this weekend.
Anyway I can't do it directly, because I don't have SVN access.
I think I'll sit here, so if you need any help...
One additional small thing is:
Index: Y:/zope/svn_zope3/src/zope/app/form/browser/metaconfigure.py
===================================================================
--- Y:/zope/svn_zope3/src/zope/app/form/browser/metaconfigure.py (revision 40192)
+++ Y:/zope/svn_zope3/src/zope/app/form/browser/metaconfigure.py (working copy)
@@ -84,7 +87,11 @@
# attribute. This can be used to override some of the
# presentational attributes of the widget implementation.
class_ = self._default_widget_factory
- self._widgets[field+'_widget'] = CustomWidgetFactory(class_, **attrs)
+ if IViewFactory.providedBy(class_):
+ #don't wrap a factory into a factory
+ self._widgets[field+'_widget'] = class_
+ else:
+ self._widgets[field+'_widget'] = CustomWidgetFactory(class_, **attrs)
def _processWidgets(self):
if self._widgets:
--
Best regards,
Adam mailto:adamg at fw.hu
--
Quote of the day:
Death is life's way of telling you you've been fired.
More information about the Zope3-dev
mailing list