[Zope3-dev] Re: absolute_url misconfiguration?

Jim Fulton jim@zope.com
Mon, 24 Mar 2003 18:31:45 -0500


Sidnei da Silva wrote:
> Hi again,
> 
> Following up with the debugging, I figured out that the problem was
> that I was using a different view type from the one registered for
> AbsoluteURL.
> 
> Currently we have,
> 
> | src/zope/app/browser/traversal.zcml has this:
> | 
> | ======================================================================
> | <page
> |     for="zope.app.interfaces.traversing.IContainmentRoot"
> |     name="absolute_url"
> |     class=".absoluteurl.SiteAbsoluteURL"
> |     permission="zope.Public"
> |     allowed_interface="zope.app.interfaces.browser.absoluteurl.IAbsoluteURL"
> |     />
> | ======================================================================
> 
> The default namespace for traversal.zcml is browser, this means that
> absolute_url is a IBrowserPresentation type. The view I was creating
> is registered as a IHTTPPresentation type. Now, if i change
> AbsoluteURL to be a IHTTPPresentation, my code starts working.

Good catch!

 > I saw
> the messages asking to make sure we are using HTTP for the server
> instead of Browser, so I suppose that the right one is to change
> AbsoluteURL to use IHTTPPresentation. However, I guess there are loads
> of other things that need to be changed beyond absolute_url. 

The thing here is that the view is not browser specific. It only
computes a URL.  It makes sense for any presentation type that deals
with URLs, which includes HTTP.

This is unique to views that deal with urls only.

> 
> Changing it to IHTTPPresentation would be:
> 
> ======================================================================
> <view
>     for="zope.app.interfaces.traversing.IContainmentRoot"
>     name="absolute_url"
>     type="zope.publisher.interfaces.http.IHTTPPresentation"
>     factory=".absoluteurl.SiteAbsoluteURL"
>     permission="zope.Public"
>     allowed_interface="zope.app.interfaces.browser.absoluteurl.IAbsoluteURL"
>     />
> ======================================================================

That looks right.


> So, now my question(s) is(are): 
> 
> 1. Should I worry about it? :)

I don't think so.

> 2. If Browser is going away, should I change everything to use HTTP?

Eek, No!  Browser isn't going away as a presentation type.  You should
use the HTTP server rather than the Borwser server because the HTTP
server handles Browser requests, XML-RPC requests and other HTTP requests.

Most browser views depend heavily on browser semantics. Certainly
views that generate HTML are.

> 3. If not, what should I do?
> 
> Im a volunteer for renaming everything from Browser to HTTP and
> make sure it works.

No. If you identify other views that *really* don't depend on browser
semantics, then you could register them for the more general HTTP
presentation type.

Jim

-- 
Jim Fulton           mailto:jim@zope.com       Python Powered!
CTO                  (703) 361-1714            http://www.python.org
Zope Corporation     http://www.zope.com       http://www.zope.org