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

Darryl Cousins darryl at darrylcousins.net.nz
Wed Sep 6 04:15:00 EDT 2006


Ok. Thanks Tahara and Philipp. I am using component.provideAdapter.

What I am having trouble with is registering ListSequenceWidget for use
in a doctest.

I believe the matching zcml from zope.form.browser configure is:

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

My own attempt to register the widget for a doctest is:


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

The error on running doctest is:

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

The relavant part of the schema to be rendered is:

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

Thanks,
Darryl


On Wed, 2006-09-06 at 09:41 +0200, Philipp von Weitershausen wrote:
> TAHARA Yusei wrote:
> > At Wed, 06 Sep 2006 09:29:15 +0200,
> > Philipp von Weitershausen wrote:
> >> TAHARA Yusei wrote:
> >>> I think you should use zope.app.testing.ztapi.provideAdapter instead.
> >> No! ztapi.provideAdapter is discouraged. zope.component.provideAdapter 
> >> is the recommended spelling.
> > 
> > Oh, sorry. I did not know that...
> 
> You couldn't have. It's not officially deprecated. It's just discouraged.
> _______________________________________________
> Zope3-users mailing list
> Zope3-users at zope.org
> http://mail.zope.org/mailman/listinfo/zope3-users



More information about the Zope3-users mailing list