<!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>>----- Original Message ----- <BR>>From:
Javier Subervi <BR>>To: zope@zope.org <BR>>Sent: Tuesday, December 12,
2006 2:29 PM<BR>>Subject: [Zope] Re: Preserving Context<BR>></FONT></P>
<P><FONT face=Arial size=2>>>The script routine doesn't have to be located
in root. traverse_subpath is <BR>>>populated using the names of all
subfolders that occur after the script file name in <BR>>>the URL.
So if your URL is: http:/my.web.site/folderA/scriptA/folderB/folderC,
<BR>>>then scriptA will receive a traverse_subpath variable (in REQUEST
namespace) <BR>>>that contains ['folderB', 'folderC']. Note: this
will not work if there are any other >scripts, DMTL methods etc in the URL
after 'scriptA'.<BR>><BR>>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 >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 >it wrong. Perhaps you could steer me right?<BR>><BR>><div
align="center" <BR>>
tal:define="mycontext
python:`here.traverse_subpath`"<BR>>
tal:condition="here/hasSearchEngine(mycontext)"><BR>><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> </DIV>
<DIV><FONT face=Arial size=2>targetFolder = string.join(traverse_subpath,
'/') #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(<some search string
here>)</FONT></DIV>
<DIV><FONT face=Arial size=2><do something with search results
here></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </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 -
Zope@zope.org<BR>http://mail.zope.org/mailman/listinfo/zope<BR>** No
cross posts or HTML encoding! **<BR>(Related lists -
<BR> http://mail.zope.org/mailman/listinfo/zope-announce<BR> http://mail.zope.org/mailman/listinfo/zope-dev
)</FONT></P></BODY></HTML>