[Zope3-dev] Re: Mini proposal: simpify presentation-lookup api
Philipp von Weitershausen
philipp at weitershausen.de
Thu Apr 1 11:18:21 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.
> """
In the docstrings, you talk about presentations, but the methods are
called {get|query}Presenter. I think they should be called
{get|query}Presentation. That's also inline with the service being
called Presentation Service, the service for Adapters being called
Adapter Service, etc. etc.
I like how this simplifies the Presentation Service API!
> Really, this just portreys presentation components as what they are:
(saying "Presentation" again).
> adapters from zero or more objects and a request to some interface.
> It also makes the desired interface required and more explicit.
That's good, since I guess we'll have BrowserViews etc. provide
IPublished...
> So, for example, a call like:
>
> view = zapi.getView(ob, name, request)
>
> will become:
>
> view = zapi.getPresenter((ob, request), someinterface, name)
How will resources be looked up?
> where often, name will be '' and can be ommitted:
Btw, why does name default to ''. I find that a little implicit. I would
much rather have it default to None.
Philipp
More information about the Zope3-dev
mailing list