Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old September 27th, 2002, 07:52 AM
mutinda mutinda is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Location: kenya
Posts: 0 mutinda User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
evaluating a dtml expression

I have a problem with this code:

<dtml-if expr="test">
<h3>Hello <dtml-var user_name> !</h3><br>
</dtml-if>

Pretty simple huh? It is meant to use "test", a zsql method, to check whether a certain username exists. The username is stored in a Postgresql database table.
(The user_name is entered on a previous form so this code is on the feedback form.)

My problem is that the "if" returns true even when there is no matching name found with the one I input. What gives?

Mutinda.
PS. This worked fine when I was evaluating variables.

Reply With Quote
  #2  
Old October 3rd, 2002, 04:51 PM
ZeUs's Avatar
ZeUs ZeUs is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Location: St. George, Utah
Posts: 63 ZeUs User rank is Sergeant Major (2000 - 5000 Reputation Level)ZeUs User rank is Sergeant Major (2000 - 5000 Reputation Level)ZeUs User rank is Sergeant Major (2000 - 5000 Reputation Level)ZeUs User rank is Sergeant Major (2000 - 5000 Reputation Level)ZeUs User rank is Sergeant Major (2000 - 5000 Reputation Level)ZeUs User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 31
Remember that expr="" attributes on DTML tags are evaluated as Python expressions.

Basically what your code is doing is seeing if there is "test" in the namespace, which there is, since you have the ZSQL method, but it's not actually calling the ZSQL Method.

Here's what you need to do:
Code:
<dtml-if expr="test(user_name - user_name)">
  <h3>Hello, <dtml-var user_name>!</h3><br>
</dtml-if>


By using "test()", with the parentheses, you are calling the method "test." And you have to pass the keyword argument because ZSQL methods only aquire the REQUEST object if they are called from the web. We are calling this one in a DTML Document or Method, so it won't aquire REQUEST.

Note that you could also pass it the entire REQUEST if you like... like this:
Code:
<dtml-if expr="test(REQUEST=_.REQUEST)">


One more thing...
Be sure user_name is in your ZSQL Method's arguments, if you pass the variable by keyword.
__________________
Lucas Marshall

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > evaluating a dtml expression


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway