|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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. |
|
#2
|
||||
|
||||
|
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 |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > evaluating a dtml expression |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|