[z3-five] Re: implementing IBrowserRequest not enough?

Philipp von Weitershausen philipp at weitershausen.de
Thu Mar 10 15:06:32 MET 2005


Jan-Wijbrand Kolman wrote:
> Hi,
> 
> A couple of questions...
> 
> 
> While trying to understand the relationships in Zope-3's interfaces for 
> requests, browser requests and application requests, I wondered if 
> Five's declaration for Zope-2's HTTPRequest is correct and complete..:
> 
> 
>   <!-- make Zope 2's REQUEST implement the right thing -->
>   <five:implements
>       class="ZPublisher.HTTPRequest.HTTPRequest"
>       interface="zope.publisher.interfaces.browser.IBrowserRequest"
>       />
> 
> 
> Questions:
> 
> 1) Does the Zope-2 HTTPRequest (including Five's monkey patch) indeed 
> implement the whole IBrowserRequest interface? I'm not sure.

Five's monkey patch is pretty unnecessary. [g|s]etPresentationSkin is 
not used in Zope 3 (not used meaning not used in production code; i 
think it's only there for test code; afaik it never was in interfaces 
and it's been removed from the trunk).

As for the rest of the interface, one would have to compare. But I think 
the bulk amount of methods and attributes are the same.

> 2) Should Five actually try to make the HTTPRequest implement 
> IBrowserRequest *and* IBrowserApplicationRequest? Maybe not, because it 
> might need too much monkeying?
> 
> However, the latter would make things like implementing 'virtual host 
> aware' breadcrumbs in Five.browser.AbsoluteUrl easier. Because 
> IBrowserApplicationRequest (or actually one of the interfaces it 
> extends) defines things like 'getVirtualHostRoot'.
> 
> Or maybe I should just implement 'my own' IAbsoluteUrl for my application?

I'm not sure what you need your custom IAbsoluteURL view to do. Virtual 
hosting in Zope 2 is delegated by a Virtual Host Monster which mangles 
the obj.absolute_url() method transparently. Since 
Five.browser.AbsoluteURL uses that good ol' method, I don't see why it 
wouldn't be virtual-host-aware. Probably I'm missing something.

I personally would like to keep the amount of monkeys in Five at a 
minimum. So, when in doubt and when we have the choice, I'd prefer using 
customizable Zope3-style components, e.g. in this case provide an 
alternate implementation of IAbsoluteURL. But again, I might be missing 
the point, so convince me otherwise :).

Philipp



More information about the z3-five mailing list