[Zope] Several users having problem accessing field names of a ZSQL Method

Dieter Maurer dieter@handshake.de
Thu, 8 Jun 2000 21:52:36 +0200 (CEST)


Jones, David H writes:
 > For example, when I use the code:
 > 
 > <dtml-in SQL.names>
 >   <dtml-let vname=sequence-item
 >   vvalue="SQL()[0][_['sequence-index']]">
 >     <dtml-var vname>,
 >    <dtml-var vvalue><br>
 >   </dtml-let>
 > </dtml-in>
 > 
 > I get the error:
 > Error Type: KeyError
 >              Error Value: SQL.names
Look careful at the error information.

It tells you, that "SQL.names" is the problem.
Because, you did not enclose it in "...", it is treated
as a variable name (i.e. equivalent to <dtml-in name="SQL.names">)
and such a variable does not exist ==> KeyError.

What you probably wanted was: <dtml-in "SQL.names">
Note the double quotation marks.
In this case, "SQL.names" is not treated as a variable name
but as a Python expression.

Probably, this will not work, either.
There are 2 further problems:
 1. "SQL" must probably be called
 2. "names" is a method and not an attribute; it must be called, too.

Try something like:
<dtml-let result=SQL> <!-- will call SQL-->
  <dtml-in "result.names()">
    <dtml-let ....
       vvalue="result[0][_['sequence-index']]">
       ....


Dieter