[Zope] Several users having problem accessing field names of a ZSQL Method
Charlie Derr
drivel_drool@bigfoot.com
Thu, 8 Jun 2000 02:40:14 -0400
~
~ I am a new Zope user and am attempting to access field names of a
~ ZSQL method. I have read and tried to use the How-To : "Access
~ the field names and fields of any arbitrary ZQSL query" by teyc.
~ The code suggested there has not worked.
~
~ 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
~
~ I have nested the above code in code that references a ZSQL
~ method, as well as trying several other permutations, but nothing
~ has worked. I'm wondering if this is a name lookup problem.
~
~ In checking this news group I see that several others have had
~ similar problems. See:
~
~ http://zope.nipltd.com/public/lists/zope-archive.nsf/Main?SearchVi
ew=++&Start=1&Count=20&SearchOrder=1&ExactMatch=&SearchOrder=1&Query=sql.nam
es
Can anyone tell me (us) how to correctly do this, or what mistake I (we) am
making.
I think i can tell you. When zope encounters something inside quotes, it
generally treats it as a python expression. Python is treating what you
thought was a hyphen as a minus sign and trying to subtract the variable
"index" from the variable "sequence" in this line of code:
<dtml-let vname=sequence-item
vvalue="SQL()[0][_['sequence-index']]">
The easy solution is to name your variable sequence_item instead of
sequence-item. I think there's also a way to actually name a variable
sequence-item, but it involves an underscore and parens _( ) and some more
funky syntax, but it's a lot easier to just stop using hyphens in variable
names.
hth,
~c
Version information:
Zope version: Zope 2.1.6 (binary release, python 1.5.2, win32-x86)
Python version: 1.5.2 (#0, Jul 30 1999, 09:52:18) [MSC 32 bit (Intel)]
Regards,
David H. Jones
Boeing Phantom Works,
Mathematics and Computing Technology
425-865-6924
425-865-2964 (FAX)
david.h.jones@boeing.com
_______________________________________________
Zope maillist - Zope@zope.org
http://lists.zope.org/mailman/listinfo/zope
** No cross posts or HTML encoding! **
(Related lists -
http://lists.zope.org/mailman/listinfo/zope-announce
http://lists.zope.org/mailman/listinfo/zope-dev )