[ZDP] BackTalk to Document The Zope Book (2.6 Edition)/Relational
Database Connectivity
webmaster at zope.org
webmaster at zope.org
Fri Jun 11 00:20:42 EDT 2004
A comment to the paragraph below was recently added via http://zope.org/Documentation/Books/ZopeBook/2_6Edition/RelationalDatabases.stx#3-67
---------------
If you call a Z SQL Method without argument from DTML, the arguments
are automatically collected from the REQUEST. This is the technique
that we have used so far in this chapter. It works well when you want
to query a database from a search form, but sometimes you want to
manually or programmatically query a database. Z SQL Methods can be
called with explicit arguments from DTML or Python. For example, to
query the *employee_by_id* Z SQL Method manually, the following DTML
can be used::
<dtml-var standard_html_header>
<dtml-in expr="employee_by_id(emp_id=42)">
<h1><dtml-var last>, <dtml-var first></h1>
<p><dtml-var first>'s employee id is <dtml-var emp_id>. <dtml-var
first> makes <dtml-var salary fmt=dollars-and-cents> per year.</p>
</dtml-in>
<dtml-var standard_html_footer>
% Anonymous User - Nov. 25, 2003 12:13 pm:
And how do you do it if you want to call it with a dtml-var as argument instead of a fix argument.
I tried <dtml-in expr="employee_by_id(emp_id=<dtml-var bidule>)"> but it didn't work
% Anonymous User - Jan. 8, 2004 1:02 pm:
Just try <dtml-in expr="employee_by_id(emp_id=`bidule`)">
I've spent 1 hour to find this *#%#2§!!!
% Anonymous User - Jan. 9, 2004 9:25 am:
or try <dtml-in expr="employee_by_id(emp_id=bidule)">
% Anonymous User - Feb. 11, 2004 10:59 am:
I tried <dtml-call expr="employee_by_id(emp_id=42)">
<dtml-var last>
But it doesnt work? I figure from reading this that it should?
% Anonymous User - Apr. 14, 2004 6:08 pm:
it's important to pass explicit arguments, when you call de ZSQL method.
<dtml-call expr="employee_by_id(emp_id=42)">
<dtml-call expr="employee_by_id(=42)"> --> this don't work
% Anonymous User - June 11, 2004 12:20 am:
For some reason, generalizing the above example so you can call it from a form:
<dtml-call expr="employee_by_id(emp_id='<dtml-var id>'">
did not work. However, this does:
<dtml-call expr="employee_by_id(emp_id=_['id'])">
More information about the ZDP
mailing list