[Zope] REQUEST.has_key does not find passed argument

Jonathan dev101 at magma.ca
Thu Aug 25 07:55:57 EDT 2005


----- Original Message ----- 
From: "Santani Teng" <steng at ucdavis.edu>
To: <zope at zope.org>
Sent: Thursday, August 25, 2005 4:27 AM
Subject: [Zope] REQUEST.has_key does not find passed argument


> Hello,
>
> I'm new to Zope, Python and DTML and could therefore use some help.
> I have a page in which I want to pass an argument to a new DTML method 
> when clicking a link. The relevant snippet is:
>
> <a href="/contact?name_id:int=<dtml-var name_id>">Contact</a>
>
> So, when you click on "Contact" you should get a new window. The variable 
> "name_id" is previously established on the page and shows up correctly 
> when the pointer hovers over the link, i.e. the status bar at the bottom 
> of the browser reads:
>
> http://server.website.edu/contact?name_id:int=3
>
> However, the DTML code for the new page doesn't seem to find this value 
> and returns a message telling me that no name was found. Because I am 
> stuck, here is the virtual entirety of the code:
>
> <dtml-if "not REQUEST.has_key('name_id')">
> No name was found. Please specify a name.
> <dtml-else>
> Thank you! The request has been made.
> </dtml-if>
>
> How can I get this page to recognize the passed argument so I can call a 
> method with it?
>
> I have seen similar threads here on this topic but was unable to find a 
> solution from reading them. I am also baffled by the fact that in large 
> part I'm reusing the same code that seems to work perfectly in the same 
> format on other pages (which I didn't write). This is probably something 
> very simple, but I would really appreciate a hand.

Your code looked ok to me so I ran a quick test using two small dtml 
methods:

dtml method 'tst':

<dtml-var standard_html_header>
<br>
<dtml-let name_id="3">
<a href="tst2?name_id:int=<dtml-var name_id>">click here</a>
</dtml-let>
<br>
<br>
<dtml-var standard_html_footer>


dtml method 'tst2':

<dtml-var standard_html_header>
<dtml-if "not REQUEST.has_key('name_id')">
 No name was found. Please specify a name.
<dtml-else>
 Thank you! The request has been made.
</dtml-if>
<dtml-var standard_html_footer>


When you run tst and then click on the 'click here' link the message 'Thank 
you! The request has been made.' appears.  Therefore your code is working as 
expected.

The only thing I can think of is that your dtml method called 'contact' is 
not being invoked properly (do you have more than 1 contact method - perhaps 
in different folders?).  Also, try removing the '/' in front of the 
'contact' in the href attribute of your html link.

hth

Jonathan 




More information about the Zope mailing list