Mystified by failed variable lookups
I have some DTML code that looks like this: ----- <dtml-let version="'2.0'"> version: <dtml-var version><br> <tr> <td width="100%" class="displayinfo"><dtml-in list_Dependencies><dtml-var sso_data></dtml-in></td> </tr> </dtml-let> ----- "list_Dependencies" is a SQL Method that calls a MySQL database. The query for list_Dependencies is: ----- SELECT sso_data FROM SSOData,ProjectNames WHERE proj_name='<dtml-var description sql_quote>' AND proj_id=sso_id AND sso_field="Dependencies" AND sso_version='<dtml-var version sql_quote>' ----- Ugly, eh? You'll note that I'm using the dtml-var "description" in the query; this is a defined property of the containing Folder object. If I do a lookup only using the 'description' property all is well; however, the SQL Method can NEVER find the 'version' variable if it is defined by FORM data (or even using dtml-let, as above). I get a KeyError. What am I not understanding here? Is there some difference between explicit properties (like those declared in the Properties page of a folder) versus FORM data or a variable declared using dtml-let? If so, why can the SQL Method see one but not the other? Awaiting enlightenment and many thanks, Andrew -- Andrew J. Templin - zope@alienminds.org Recovering Sysadmin/Confused Programmer/Cosmic Stir Stick/Meta-Paranoid PGP & GPG keys available at http://www.alienminds.org/~nosilla/ "After the data was wiped, the claymores would detonate" - Andrew Downie
Andrew J. Templin writes:
I have some DTML code that looks like this:
----- <dtml-let version="'2.0'"> ... <dtml-in list_Dependencies> ... "list_Dependencies" is a SQL Method that calls a MySQL database.
The query for list_Dependencies is:
----- SELECT sso_data FROM SSOData,ProjectNames WHERE proj_name='<dtml-var description sql_quote>' AND proj_id=sso_id AND sso_field="Dependencies" AND sso_version='<dtml-var version sql_quote>' ... I get a KeyError. You get a "KeyError" for "version" because the DTML namespace is not passed into Z SQL methods. You must either pass the arguments to the Z SQL methods through a sequence of keyword arguments or (exclusive) through "REQUEST".
Read the Z SQL chapter in the Zope book. It will tell you the details. Dieter
[Andrew J. Templin]
I have some DTML code that looks like this:
----- <dtml-let version="'2.0'"> version: <dtml-var version><br> <tr> <td width="100%" class="displayinfo"><dtml-in list_Dependencies><dtml-var sso_data></dtml-in></td> </tr> </dtml-let> -----
"list_Dependencies" is a SQL Method that calls a MySQL database.
The query for list_Dependencies is:
----- SELECT sso_data FROM SSOData,ProjectNames WHERE proj_name='<dtml-var description sql_quote>' AND proj_id=sso_id AND sso_field="Dependencies" AND sso_version='<dtml-var version sql_quote>' -----
Ugly, eh?
You haven't seen anything if you think that's ugly!
You'll note that I'm using the dtml-var "description" in the query; this is a defined property of the containing Folder object. If I do a lookup only using the 'description' property all is well; however, the SQL Method can NEVER find the 'version' variable if it is defined by FORM data (or even using dtml-let, as above). I get a KeyError.
What am I not understanding here? Is there some difference between explicit properties (like those declared in the Properties page of a folder) versus FORM data or a variable declared using dtml-let? If so, why can the SQL Method see one but not the other?
Sounds like you need to define the arguments for the ZSQL method. You didn't say you had done that. If you didn't, go define all the arguments that you use (like "version") and try it again. Cheers, Tom P
participants (3)
-
Andrew J. Templin -
Dieter Maurer -
Thomas B. Passin