[Zope3-Users] Registering adapter for ListSequence widget in tests

Darryl Cousins darryl at darrylcousins.net.nz
Wed Sep 6 00:55:16 EDT 2006


Hi,

I am having problems registering ListSequence widget, the following from my doctest:

Although most widget adapters are registered in tfws.form.browser testing I had
a lot of trouble with ListSequenceWidget - here I keep trying until I get it.

This is the error raised when running the test::

    ComponentLookupError: ((<zope.schema._field.List object at 0xb704532c>,
    <zope.publisher.browser.TestRequest instance URL=http://127.0.0.1>),
    <InterfaceClass zope.app.form.interfaces.IInputWidget>, u'')

If I can't get the widget registered for the test then I shall just have to give
up on the test.

All this is to try to register an adpater to IInputWidget for the schema::

    addlanguage = List(
        title = _("Language"),
        description = _("Add language to content"),
        required = False,
        default = [],
        value_type = TextLine(
            title = _("Langauge")))

It **does** work in the browser.

Imports::

    >>> from zope.component import provideAdapter
    >>> from zope.app.form.browser import ListSequenceWidget
    >>> from zope.schema.interfaces import IList, IField
    >>> from zope.app.form.interfaces import IInputWidget
    >>> from zope.publisher.interfaces.browser import IBrowserRequest

The zcml configure for same looks like this in zope.app.form.browser.configure::

    <view
        type="zope.publisher.interfaces.browser.IBrowserRequest"
        for="zope.schema.interfaces.IList
             zope.schema.interfaces.IField"
        provides="zope.app.form.interfaces.IInputWidget"
        factory=".ListSequenceWidget"
        permission="zope.Public"
        />

Following test setup formula in zope.app.form.browser I get this:

    >>> provideAdapter(ListSequenceWidget,[IList,IField,IBrowserRequest], \
    ...                        IInputWidget,)

But no go. See error above.

Best regards,
Darryl



More information about the Zope3-users mailing list