>----- Original Message ----- >From: Javier Subervi >To: zope@zope.org >Sent: Tuesday, December 12, 2006 2:29 PM >Subject: [Zope] Re: Preserving Context >
>>The script routine doesn't have to be located in root. traverse_subpath is >>populated using the names of all subfolders that occur after the script file >>name in >>the URL. So if your URL is: >>http:/my.web.site/folderA/scriptA/folderB/folderC, >>then scriptA will receive a traverse_subpath variable (in REQUEST namespace) >>that contains ['folderB', 'folderC']. Note: this will not work if there are >>any other >scripts, DMTL methods etc in the URL after 'scriptA'. > >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? > ><div align="center" > tal:define="mycontext python:`here.traverse_subpath`" > tal:condition="here/hasSearchEngine(mycontext)"> > 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)). 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: targetFolder = string.join(traverse_subpath, '/') #you will have to play with this to get the right target folder for your app aFolder = context.restrictedTraverse(targetFolder) searchRes = aFolder.Catalog(<some search string here>) <do something with search results here> Jonathan Any questions? Get answers on any topic at Yahoo! Answers. Try it now. _______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )