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")
        )
)

helper.py:
from zope.app.form import CustomWidgetFactory
from zope.app.form.browser import OrderedMultiSelectWidget

OrderedMultiSelectWidget_factory = CustomWidgetFactory(OrderedMultiSelectWidget)

configure.zcml:
...
  <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:widget field="szerepek" 
class=".helper.OrderedMultiSelectWidget_factory"/>
  </browser:addform>
...

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>
>>
>>
DH> You cannot register the widget class directly, but you have to provide a
DH> specific widget factory.
DH> Example edit.py within your browser directory:

DH> from zope.app.form import CustomWidgetFactory
DH> from zope.app.form.browser import OrderedMultiSelectWidget

DH> szerepek_widget_factory =
DH> CustomWidgetFactory(OrderedMultiSelectWidget)


DH> Example registration within the configure.zcml:

DH>   <browser:addform
DH>       schema="szscreen.interfaces.ISzemely"
DH>       content_factory="szscreen.app.Szemely"
DH>       label="Uj Szemely"
DH>       name="AddSzemely.html"
DH>       permission="zope.ManageContent"
DH>       set_before_add="name"
DH>       >
DH>       <widget field="szerepek"
DH> class=".edit.szerepek_widget_factory"/>
DH>   </browser:addform>

DH> Regards,
DH> Dominik


-- 
Best regards,
 Adam                            mailto:[EMAIL PROTECTED]
--
Quote of the day:
A certain amount of opposition is a great help to a man. Kites rise against, 
not with the wind. 
- John Neal 

_______________________________________________
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com

Reply via email to