[Zope-CMF] I can't live without DTML in Portal Document
Tres Seaver
tseaver@zope.com
Wed, 10 Oct 2001 08:23:02 -0400
Florent Guillaume wrote:
>Loren Stafford wrote:
>>Not a great subject line, but I'm having trouble expressing the real problem
>>in a few words. So here are a lot of words:
>>
>>On my Intranet site, I've got a Portal Folder
>>
>> http://morphicsweb//Portal/Members/lstaffor/Papers/2001_09_01/,
>>
>>and in that folder a Document (Format HTML) called 'index_html' and a Portal
>>Image 'Fig_1.gif'. In 'index_html' I reference the image with <img
>>src="../Fig_1.gif">. When I click the View action the document is requested
>>with the URL
>>
>>
>>http://morphicsweb/Portal/Members/lstaffor/Papers/2001_09_01/index_html/docu
>>ment_view
>>
>>and the browser expands the 'img' reference to
>>
>> http://morphicsweb/Portal/Members/lstaffor/Papers/2001_09_01/Fig_1.gif
>>
>>and all is well.
>>
>>However, if I find the document by a Topic search, the document is requested
>>with the URL
>>
>> http://morphicsweb/Portal/Members/lstaffor/Papers/2001_09_01/index_html
>>
>>and the browser expands the 'img' reference to
>>
>> http://morphicsweb/Portal/Members/lstaffor/Papers/Fig_1.gif
>>
>>which is invalid, since Fig_1.gif is not in that folder.
>>
>>I've made a temporary fix by coding the absolute URL of the image in the img
>>tag, but, until now, I haven't had to code absolute URLs since I started
>>using Zope. I usually generate them with DTML, but I can't use DTML in a
>>Portal Document. I could play a trick with acquisition, moving the image up
>>one level (or the index_html Document down one level); but that would still
>>be a trick.
>>
>>What is the right solution to this problem? What is the real problem?
>>
>
> I believe that Document (and other contents in general) should insert a
> <base> tag in the <head> in some situations, but I've not yet completely
> figured out the mechanism used (it's fairly intricate and not very well
> documented -- see HTTPResponse::insertBase, and the call to
> response.setBase in BaseRequest::traverse ...).
>
> Your best bet in the meantime, as you mentionned, would be acquisition,
> which is not that much of a hack (except that it can lead to
> caching-unfriendly behaviour).
Note that the default skiins for content objects already set
the BASE tag, for just this reason. Here is 'document_view'::
<dtml-let relative_to_content="1">
<dtml-var standard_html_header>
</dtml-let>
<div class="Desktop">
<div class="Document">
<dtml-var content_byline>
<dtml-var CookedBody>
<div class="Discussion">
<dtml-var viewThreadsAtBottom>
</div>
</div>
</div>
<dtml-var standard_html_footer>
That 'relative_to_content' flag causes 'standard_html_header' to
insert a base tag with the current object's 'absolute_url'. I think
this is still broken in CMFDecor, however.
Tres.
--
===============================================================
Tres Seaver tseaver@zope.com
Zope Corporation "Zope Dealers" http://www.zope.com