[Zope3-Users] stuck with zope.schema.List and subwidget

Christian Lueck christian.lueck at ruhr-uni-bochum.de
Fri Aug 26 19:01:04 EDT 2005


Did anyone ever test or succeed using the subwidget-directive of

Following the lines of zope/app/form/browser/widgets.txt a widget for a
list of objects would be defined by something like this:

author_w = CustomWidgetFactory(ObjectWidget, Person)

class ArticleEditView(EditView):
    authors_widget = CustomWidgetFactory(SequenceWidget, subwidget=author_w)

Instead of SequenceWidget I tried ListSequenceWidget, too.

But I allways get the error-message:
__init__() takes at least 4 arguments (3 given)

I'm really stuck. Which further argument should I pass to
CustomWidgetFactory? CustomWidgetFactory--if I get it right--calls the
constructur of SequenceWidget that complains about the missing argument.
(self, context, field, request, subwidget=None) is the list of arguments
of __init__
Especially: What should I pass as 'field'-argument?
I played around with the source code and changed the list to (self,
context, request, subwidget=None) and--WOW-- it presents a form yust as
I want it. [Now I allways get a new (schema-)error, which I can't track:
"Es gab *1* Eingabefehler."]

The constructor of SequenceWidget reads like this:

def __init__(self, context, field, request, subwidget=None):
        super(SequenceWidget, self).__init__(context, request)
        self.subwidget = subwidget

I really don't understand what is done with 'field'. Where is it passed

Can someone give me a hint?

Kind regards,

PS. I found a way to define a widget for objects of objects yesterday,
see zope3-users. The example above is taken from there.

More information about the Zope3-users mailing list