[Zope3-dev] problems with <browser:widget>

Roger Ineichen dev at projekt01.ch
Fri Aug 26 10:10:46 EDT 2005


Hi Adam

> Behalf Of Adam Groszer
> Sent: Friday, August 26, 2005 3:24 PM
> To: Dominik Huber
> Cc: zope3-dev
> Subject: Re[2]: [Zope3-dev] problems with <browser:widget>
> 
> Dear Dominik,
> 
> I implemeted what you told me, but I'm still out of luck.
> (The szerep/szemely mistake as noticed by Dylan Reinhardt was mine,
> but you got the real problem.
> 
> class ISzemely(Interface):
> ...
>     szerepek = List(
>         title=u"Hozzarendelt szerepek",
>         description=u"Hozzarendelt szerepek",
>         required=False,
>         value_type=Choice(vocabulary="szerep")
>         )
> )
> 

[snip]

> 
> The exception is a little bit different, but the end result is the
> same.
> 
> ...
>   Module zope.interface.adapter, line 481, in queryMultiAdapter
>     return factory(*objects)
>   Module zope.app.form.browser.editview, line 64, in __init__
>     self._setUpWidgets()
>   Module zope.app.form.browser.add, line 49, in _setUpWidgets
>     setUpWidgets(self, self.schema, IInputWidget, 
> names=self.fieldNames)
>   Module zope.app.form.utility, line 153, in setUpWidgets
>     context=context)
>   Module zope.app.form.utility, line 101, in setUpWidget
>     widget = widget(field.bind(context), view.request)
>   Module zope.app.form, line 97, in __call__
>     instance = self._widget_factory(*args)
>   Module zope.app.form, line 97, in __call__
>     instance = self._widget_factory(*args)
> TypeError: __init__() takes exactly 4 arguments (3 given)
> 
> As I checked the worldcookery example it does not use a factory either
> and it is working fine.
> 
>   
> Wednesday, August 24, 2005, 4:01:07 PM, you wrote:
> 
> DH> Adam Groszer wrote:
> 
> >>I'm having problems with using <browser:widget>.
> >>
> >>I have an interface:
> >>class ISzerep(Interface):
> >>    name = TextLine(
> >>        title=u"Szerep nev",
> >>        description=u"Szerep nev",
> >>        required=True
> >>        )
> >>    szemelyek = List(
> >>        title=u"Hozzarendelt szemelyek",
> >>        description=u"Hozzarendelt szemelyek",
> >>        required=False,
> >>        value_type=Choice(vocabulary="szemely")
> >>        )
> >>
> >>If I add a simple add (or edit) form:
> >>  <browser:addform
> >>      schema="szscreen.interfaces.ISzemely"
> >>      content_factory="szscreen.app.Szemely"
> >>      label="Uj Szemely"
> >>      name="AddSzemely.html"
> >>      permission="zope.ManageContent"
> >>      set_before_add="name"
> >>      >
> >>  </browser:addform>
> >>everything goes well, an OrderedMultiSelectWidget is 
> displayed in the
> >>browser by default for the *szemelyek* field.
> >>
> >>If I modify the addform configuration by adding the <widget>:
> >>  <browser:addform
> >>      schema="szscreen.interfaces.ISzemely"
> >>      content_factory="szscreen.app.Szemely"
> >>      label="Uj Szemely"
> >>      name="AddSzemely.html"
> >>      permission="zope.ManageContent"
> >>      set_before_add="name"
> >>      >
> >>      <widget field="szerepek"
> >> class="zope.app.form.browser.OrderedMultiSelectWidget"/>
> >>  </browser:addform>

Just a quick note:

If you use a List of Choice, I guess you need a 
"custom sequence widget factory" not a custom widget factory".
        --------       
I implemented such a base factory in zope.app.form.__init__.py

"CustomSequenceWidgetFactory"

There is also a test for this at:

zope.app.form.browser.tests.test_sequencewidget.py

btw;
I'm not sure right now if this is really the problem since
I didn't follow the tread at all.

Regards
Roger Ineichen



More information about the Zope3-dev mailing list