[Zope] Including Script-Generated String in Method Call

Dan Shafer dan@gui.com
Sun, 30 Dec 2001 00:56:16 -0800


At 2:14 PM +0800 12/30/01, Bak @ kedai wrote:
>I have been chasing my tail on this one for the better part of two
>hours now. Time to ask for help.
>
>My goal:
>
>I want to load a page whose URL looks like "day1.html" where the
>number in the name of the page changes.
>
>I have written a Python script called pagetoget which calculates the
>day number correctly and assembles the URL as a string, which it
>returns. This seems to work.
>
>
>----
>what you can try:
><dtml-var "_.getitem(pagetoget)">

Thanks very much for your quick responses!

This produces an AttributeError, with an ErrorValue: _hash_.

>checkout dieter's chap3 in his book available on the net (search the archive
>for the url)
>
>to redirect, you can do this
><dtml-call "RESPONSE.redirect(pagetoget)">

As this is given, it produces a Site Error because Zope is looking 
for the URL of the Python script. I get "can't find resource 
'/PythonScript%20instance....' on the error page.

Perhaps I need my Python script to be an external method? Right now, it isn't.

FWIW, the Python script (name=pagetoget), simplified so you can see 
what I'm trying to do more clearly, is simple:

daynum=1  #in the real script, this is a calculation but I've elimianted it
return 'http://www.mysite.com/fuzz'+daynum+'.html'

I'm pretty sure this returns a string that at least looks like a URL 
because if I just use:

<dtml-var pagetoget>

I get a page with the URL I expect to see 
(http://www.mysite.com/fuzz1.html) displayed.

>rule # 666 in the road to zen:  no dtml in dtml

Thanks. That's an easy rule to remember!

>rule #69 states : if in " ", you're in python realm.

Ditto.

>:)
>
>hth


-- 
Dan Shafer, Author-Consultant
http://www.danshafer.com
http://www.shafermedia.com