[Zope] Question about the base href that Zope adds automatica lly

Thom Wysong TWysong@DevIS.com
Thu, 8 Nov 2001 18:12:39 -0500


Pieter Claerhout wrote:
>>> can anyone explain me why zope always adds the <base
href="http://my.server.com/" /> to every HTML file it's serving. .... is
there an easy way to get rid of this if it's not necessary? <<<

We just ran into this same problem today. We explored many options,
including commenting the "self.insertBase" line out of HTTPResponse.py. What
ended up being the simplest solution, as was mentioned earlier in this
thread, is adding <base /> to our html files immediately following the
<head> tag. 

<html>
<head>
   <base />
   <title>Joe's Web Site</title>
</head>
<body>
   Welcome to Joe's Web Site.
</body>
</html>

This is enough of a tag that Zope leaves the html alone and does not insert
its own <base> tag. Yet, it's not enough information for the browser to do
anything with. So the browser ignores the tag and dynamically figures out
the BASE variable for each page on the web site. 

In practical terms, this ended up having the same affect as commenting
"self.insertBase" out of the source code - but without having to remember to
re-comment-out that line every time we upgrade our version of Zope.

The only caveat that we've found with this, as was also mentioned earlier in
this thread, is that every link to a directory on the site needs to end with
a slash. Zope returns a "Resource not found" error when attempting to link
to a directory that ends without a slash.

Bad Link : <a href="directory_one">Directory One</a> 
Good Link: <a href="directory_one/">Directory One</a> 

-Thom