[Zope] VHM and hard-wired URLs generated by stock Zope code

Richard Barrett R.Barrett@ftel.co.uk
Tue, 06 Nov 2001 17:42:28 +0000


At 14:35 06/11/2001 +0000, Richard Barrett wrote:
>Running Zope 2.3.3 with python 1.5.2
>
>I run Zope on a private IP numbered server for users on our LAN but expose 
>some parts of the Zope tree via Apache using ProxyPass and VHM to adjust 
>the URLs on our pages.
>
>The problem I'm having is with some of the hard-wired URLs produced by 
>some of the standard Zope code. For instance, the dtml-tree tag generates 
>things like:
>
><IMG SRC="/p_/mi" ALT="-" BORDER=0>
>
>The ZMI also does the same although that is less of a problem as, in 
>general, I do not use the ZMI through the Apache proxy. But I might want 
>to in the future.
>
>I do not want to use extra ProxyPass directives in my Apache config to 
>handle these "unadjustable" hard-wired URLs. Aside from hacking at the 
>source code does anyone know of a clean solution for this problem.

I did create a partial solution to this problem. The code in TreeTag.py 
that generates the /p_/mi and /p_/pl URLs appears to prefix them with the 
contents of the variable REQUEST['SCRIPT_NAME'. By using REQUEST.set() to 
force the value of this to one appropriate to the request target, using the 
absolute_url function, the IMG SRC URLs come out as appropriately VHM 
adjusted URLs. When the browser feeds these URLs back to the server whether 
via the Apache proxy or by direct request to Zope, Zope acquisition finds 
the required files. For instance, my DTML method for building the tree view 
HTML looks like:

<dtml-call "REQUEST.set('SCRIPT_NAME', absolute_url())">
<dtml-tree sort="title" branches_expr="listObjectsForTree(['File', 
'Folder', 'ExtFile', 'DTML Document'])">
   <div class="maintext">
     <dtml-if "meta_type=='Folder'">
         <dtml-var title_or_id>
     <dtml-else>
         <a href="<dtml-var absolute_url>"><dtml-var title_or_id></a>
     </dtml-if>
   </div>
</dtml-tree>

The result is no additional ProxyPass needed for Apache to access the /p_ URLs.

If anybody has better idea, I'd love to hear it because my solution is a 
really disgusting hack. That said, the whole /p_ and /misc_ URL thing is 
pretty ugly in my view.