[Zope3-dev] RFC: CustomWidgetFactory and widgets having different
__init__ signature
Adam Groszer
adamg at fw.hu
Sat Nov 12 15:43:34 EST 2005
As I'm digging through zope.app.form.browser to fix the
CustomWidgetFactory collector issue, I found the following:
IWidget has no __init__ defined
class Widget(object):
def __init__(self, context, request):
class ItemsWidgetBase(TranslationHook, SimpleInputWidget):
def __init__(self, field, vocabulary, request):
class ItemsEditWidgetBase(SingleDataHelper, ItemsWidgetBase):
def __init__(self, field, vocabulary, request):
class ObjectWidget(BrowserWidget, InputWidget):
def __init__(self, context, request, factory, **kw):
class SequenceWidget(BrowserWidget, InputWidget):
def __init__(self, context, field, request, subwidget=None):
class SequenceDisplayWidget(DisplayWidget):
def __init__(self, context, field, request, subwidget=None):
class SourceDisplayWidget(zope.app.form.Widget):
def __init__(self, field, source, request):
class SourceInputWidget(zope.app.form.InputWidget):
def __init__(self, field, source, request):
class SourceSelectWidget(zope.app.form.browser.SelectWidget):
def __init__(self, field, source, request):
CustomWidgetFactory fails on these different signatures. This affects
the ZCML <browser:widget field="..." class="..."/>. Simple widgets
will work, widgets with different signatures of course not.
class CustomWidgetFactory(object):
implements(IViewFactory)
def __call__(self, context, request):
class CustomSequenceWidgetFactory(object):
implements(IViewFactory)
def __call__(self, context, field, request):
In fact, CustomSequenceWidgetFactory violates the IViewFactory
interface with the different __call__ signature. That causes
setUpWidget to fail. I'm wondering if this worked for anyone anytime.
Now I'm stuck a little bit. How does a good solution look like?
My half-baked solution was up to today for Itemswidgets (which caused
the error for me) to mark it with a different interface and look for
that in CustomWidgetFactory and pass different arguments.
Now I'm not so sure that this is the right one.
--
Best regards,
Adam mailto:adamg at fw.hu
--
Quote of the day:
Every person should have a special cemetery lot in which to bury the faults of friends and loved ones.
- Anonymous
More information about the Zope3-dev
mailing list