[Zope3-dev] Re: Mini proposal: simpify presentation-lookup api

Tres Seaver tseaver at zope.com
Thu Apr 1 13:51:31 EST 2004


Jim Fulton wrote:

> I propose to replace these with:
> 
>     def queryPresenter(objectsandrequest, interface, name='',
>                        default=None, context=None):
>         """Query a presentation for the objects and request
> 
>         A components is returned that provides the given interface for
>         the given objects and request. The objects and request are
>         provides as a tuple. The request must be the last item in the
>         tuple.  Zero or more non-request objects may be provided.
>         A name may be provided to quality the presentation.
> 
>         If a presentation can't be found, the default is returned.
> 
>         A context may be provided to control where components are looked 
> up.
>         """
> 
>     def getPresenter(objectsandrequest, interface, name='',
>                      default=None, context=None):
>         """Get a presentation for the objects and request
> 
>         A components is returned that provides the given interface for
>         the given objects and request. The objects and request are
>         provides as a tuple. The request must be the last item in the
>         tuple.  Zero or more non-request objects may be provided.
>         A name may be provided to quality the presentation.
> 
>         If a presentation can't be found, a ComponentLookupError is raised.
> 
>         A context may be provided to control where components are looked 
> up.
>         """

-1 to 'objectsandrequest';  if the request is special, and required, and 
must be in a specific position, then it should not be "lumped" with the 
objects.  Why not:

     def getPresenter(request, interface, objects=(), name='',
                      default=None, context=None):
         """..."""

Because presenters are *always* adapting requests to an interface, but 
*may* take into account other objects, and *may* have a name, this seems 
cleaner.  We could move the interface to be first, if that makes it clearer.

Tres.
-- 
===============================================================
Tres Seaver                                tseaver at zope.com
Zope Corporation      "Zope Dealers"       http://www.zope.com




More information about the Zope3-dev mailing list