Forcing Zope to render a URL
Is there a way to have Zope render, as part of a DTML method, a specific URL in order to take advantage of direct traversal. For example, I tried this DTML code: <!--#var "URL4 + '/Templates/' + _.str(_['template'])"--> This gives me the perfect URL, but in text format. Does anyone know of a way to make #var render that URL? All the best, -- Jason Spisak webmaster@mtear.com
At 19:06 10/05/99 , Jason Spisak wrote:
Is there a way to have Zope render, as part of a DTML method, a specific URL in order to take advantage of direct traversal. For example, I tried this DTML code:
<!--#var "URL4 + '/Templates/' + _.str(_['template'])"-->
This gives me the perfect URL, but in text format. Does anyone know of a way to make #var render that URL?
All the best,
-- Jason Spisak webmaster@mtear.com
You mean something like: <!--#with Templates--> <!--#var "_.getitem('template', 1)"--> <!--#/with--> or do you mean: <!--#with Templates--> <!--#var "_.getitem(_[template], 1)"--> <!--#/with--> The first being: Render the object named ´template´ within the object ´Templates´. and the second: Render the object named by the variable ´template´ within the object ´Templates´. -- Martijn Pieters, Web Developer | Antraciet http://www.antraciet.nl | Tel: +31-35-6254545 Fax: +31-35-6254555 | mailto:mj@antraciet.nl http://www.antraciet.nl/~mj | PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149 ------------------------------------------
Martijn, Once again Martijn you were able to help more than I could help you. A debt I hope to repay someday. :) The second was what I was trying to achieve. I tried the getitem, but I put single quote around it so it rendered the text. Duh. Thanks again, you DTML stud! All my best, -- Jason Spisak webmaster@mtear.com Martijn Pieters wrote:
You mean something like:
<!--#with Templates--> <!--#var "_.getitem('template', 1)"--> <!--#/with-->
or do you mean:
<!--#with Templates--> <!--#var "_.getitem(_[template], 1)"--> <!--#/with-->
The first being: Render the object named ´template´ within the object ´Templates´. and the second: Render the object named by the variable ´template´ within the object ´Templates´.
Martijn, Just a quick followup, using:
<!--#with Templates--> <!--#var "_.getitem(_[template], 1)"--> <!--#/with-->
Oddly enough it works and I get a traceback! Both. I've never seen Zope do this before, any ideas? It rendered the page in *full*, then tacked a traceback onto it. The traceback that got tacked on is this: <PRE> Traceback (innermost last): File /home/jason/Zope/lib/python/ZPublisher/Publish.py, line 255, in publish_module File /home/jason/Zope/lib/python/ZPublisher/Publish.py, line 157, in publish File /home/jason/Zope/lib/python/ZPublisher/mapply.py, line 154, in mapply (Object: index_html) File /home/jason/Zope/lib/python/ZPublisher/Publish.py, line 98, in call_object (Object: index_html) File /home/jason/Zope/lib/python/OFS/DTMLMethod.py, line 157, in __call__ (Object: index_html) File /home/jason/Zope/lib/python/OFS/DTMLMethod.py, line 153, in __call__ (Object: index_html) File /home/jason/Zope/lib/python/DocumentTemplate/DT_String.py, line 513, in __call__ (Object: index_html) File /home/jason/Zope/lib/python/DocumentTemplate/DT_With.py, line 148, in render (Object: Contract_Templates) File /home/jason/Zope/lib/python/DocumentTemplate/DT_Util.py, line 295, in eval (Object: _.getitem(_[template],1)) File <string>, line 0, in ? KeyError: (see above) </PRE>ª It thinks it had a problem with it, but it rendered it anyway? -- Jason Spisak webmaster@mtear.com
Martijn, Finally I put my single quotes back in when I realized that that wasn't the problem, now it works. The final snipet looks like this: <!--#with Templates--> <!--#var "_.getitem(_['template'], 1)"--> <!--#/with--> Thanks again for your help! Jason Spisak webmaster@mtear.com
participants (2)
-
Jason Spisak -
Martijn Pieters