<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<STYLE type=text/css></STYLE>

<META content="MSHTML 6.00.5730.11" name=GENERATOR></HEAD>
<BODY bgColor=#ffffff background=""><FONT face=Arial size=2></FONT><FONT 
face=Arial size=2></FONT>
<P><BR><FONT face=Arial size=2>&gt;----- Original Message ----- <BR>&gt;From: 
Javier Subervi <BR>&gt;To: zope@zope.org <BR>&gt;Sent: Tuesday, December 12, 
2006 2:29 PM<BR>&gt;Subject: [Zope] Re: Preserving Context<BR>&gt;</FONT></P>
<P><FONT face=Arial size=2>&gt;&gt;The script routine doesn't have to be located 
in root.&nbsp; traverse_subpath is <BR>&gt;&gt;populated using the names of all 
subfolders that occur after the script file name in <BR>&gt;&gt;the URL.&nbsp; 
So if your URL is:&nbsp; http:/my.web.site/folderA/scriptA/folderB/folderC, 
<BR>&gt;&gt;then scriptA will receive a traverse_subpath variable (in REQUEST 
namespace) <BR>&gt;&gt;that contains ['folderB', 'folderC'].&nbsp; Note: this 
will not work if there are any other &gt;scripts, DMTL methods etc in the URL 
after 'scriptA'.<BR>&gt;<BR>&gt;I figured out what I was doing wrong. 
Apparently, the script needs to be called *before* the folders. I had put it at 
the end. Okay, that &gt;works, so now how do I incorporate it? I'm running into 
trouble here. I've rewritten the following line several times, and several times 
gotten &gt;it wrong. Perhaps you could steer me right?<BR>&gt;<BR>&gt;&lt;div 
align="center" <BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
tal:define="mycontext 
python:`here.traverse_subpath`"<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
tal:condition="here/hasSearchEngine(mycontext)"&gt;<BR>&gt;<BR></FONT></P>
<P><FONT face=Arial size=2>Your page template just needs to construct a URL 
(that your users can access - eg. in an html link) that contains the name of the 
script file at the beginning of the URL (ie. before the target 
subfolder(s)).</FONT></P>
<DIV><FONT face=Arial size=2>The script file will have to use the 
traverse_subpath contents to build a string which you can then use to access the 
required folder:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>targetFolder = string.join(traverse_subpath, 
'/')&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; #you will have to play with this to 
get the right target folder for your app</FONT></DIV>
<DIV><FONT face=Arial size=2>aFolder = 
context.restrictedTraverse(targetFolder)</FONT></DIV>
<DIV><FONT face=Arial size=2>searchRes = aFolder.Catalog(&lt;some search string 
here&gt;)</FONT></DIV>
<DIV><FONT face=Arial size=2>&lt;do something with search results 
here&gt;</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Jonathan</DIV>
<P><BR><BR>Any questions? Get answers on any topic at Yahoo! Answers. Try it 
now.<BR><BR><BR><BR>_______________________________________________<BR>Zope 
maillist&nbsp; -&nbsp; 
Zope@zope.org<BR>http://mail.zope.org/mailman/listinfo/zope<BR>**&nbsp;&nbsp; No 
cross posts or HTML encoding!&nbsp; **<BR>(Related lists - 
<BR>&nbsp;http://mail.zope.org/mailman/listinfo/zope-announce<BR>&nbsp;http://mail.zope.org/mailman/listinfo/zope-dev 
)</FONT></P></BODY></HTML>