simple question about <!--#if expr="fieldname = 't'"-->
I'm having trouble making a simple text comparison (my very first in Zope). I can get Zope to give me results for just <!--#var fieldname-->, but not for <!--#if expr="fieldname = 't'"-->yes<!--else-->no<!--#/if>. I'm using the following code: <!--#in queryobjectname--> <tr> <font size="2" face="Arial Narrow"> <td><!--#if expr="fieldname = 't'"-->yes<!--else-->no<!--#/if></td> </tr> <!--#/in--> Here's the error I get: Zope Error Zope has encountered an error while publishing this resource. Error Type: SyntaxError Error Value: invalid syntax Traceback (innermost last): File /usr/local/zope/230/lib/python/ZPublisher/Publish.py, line 222, in publish_module File /usr/local/zope/230/lib/python/ZPublisher/Publish.py, line 187, in publish File /usr/local/zope/230/lib/python/Zope/__init__.py, line 221, in zpublisher_exception_hook (Object: index_html) File /usr/local/zope/230/lib/python/ZPublisher/Publish.py, line 171, in publish File /usr/local/zope/230/lib/python/ZPublisher/mapply.py, line 160, in mapply (Object: manage_edit) File /usr/local/zope/230/lib/python/ZPublisher/Publish.py, line 112, in call_object (Object: manage_edit) File /usr/local/zope/230/lib/python/OFS/DTMLDocument.py, line 144, in manage_edit (Object: index_html) File /usr/local/zope/230/lib/python/DocumentTemplate/DT_String.py, line 388, in munge (Object: index_html) File /usr/local/zope/230/lib/python/DocumentTemplate/DT_String.py, line 408, in cook (Object: index_html) File /usr/local/zope/230/lib/python/DocumentTemplate/DT_String.py, line 242, in parse (Object: index_html) File /usr/local/zope/230/lib/python/DocumentTemplate/DT_String.py, line 292, in parse_block (Object: index_html) File /usr/local/zope/230/lib/python/DocumentTemplate/DT_String.py, line 242, in parse (Object: index_html) File /usr/local/zope/230/lib/python/DocumentTemplate/DT_String.py, line 305, in parse_block (Object: index_html) File /usr/local/zope/230/lib/python/DocumentTemplate/DT_If.py, line 165, in __init__ File /usr/local/zope/230/lib/python/DocumentTemplate/DT_Util.py, line 386, in name_param (Info: ({'expr': "fieldname = 't'"}, 'if', 1, 'name')) File /usr/local/zope/230/lib/python/DocumentTemplate/VSEval.py, line 166, in __init__ (Object: fieldname = 't') SyntaxError: (see above)
Donald Braman wrote:
I'm having trouble making a simple text comparison (my very first in Zope).
<td><!--#if expr="fieldname = 't'"-->yes<!--else-->no<!--#/if></td>
(Object: fieldname = 't') SyntaxError: (see above)
I think it's because you used the assignment operator '=' instead of the comparison operator '=='. -- Tim Cook, President - FreePM,Inc. http://www.FreePM.com Office: (901) 884-4126 New MedicationManager, Try it now at: http://www.freepm.org:8080/FreePM
Works! One million thanks! Is that documented anywhere? -Don -----Original Message----- From: tim@mr1.its.yale.edu [mailto:tim@mr1.its.yale.edu]On Behalf Of Tim Cook Sent: Monday, February 19, 2001 9:38 PM To: donald.braman@yale.edu Cc: zope@zope.org Subject: Re: [Zope] simple question about <!--#if expr="fieldname = 't'"--> Donald Braman wrote:
I'm having trouble making a simple text comparison (my very first in Zope).
<td><!--#if expr="fieldname = 't'"-->yes<!--else-->no<!--#/if></td>
(Object: fieldname = 't') SyntaxError: (see above)
I think it's because you used the assignment operator '=' instead of the comparison operator '=='. -- Tim Cook, President - FreePM,Inc. http://www.FreePM.com Office: (901) 884-4126 New MedicationManager, Try it now at: http://www.freepm.org:8080/FreePM
Donald Braman wrote:
Works! One million thanks! Is that documented anywhere? -Don
I think it's because you used the assignment operator '=' instead of the comparison operator '=='.
Probably in the ZQR, and other places. -- Tim Cook, President - FreePM,Inc. http://www.FreePM.com Office: (901) 884-4126 New MedicationManager, Try it now at: http://www.freepm.org:8080/FreePM
Tim Cook wrote:
Donald Braman wrote:
Works! One million thanks! Is that documented anywhere? -Don
I think it's because you used the assignment operator '=' instead of the comparison operator '=='.
Probably in the ZQR, and other places.
Yeah, like the Python Language reference ;-) *grinz* Chris PS: I'd suggest movign to the <dtml-if expr=""> syntax, it's much nicer on the eyes...
On Tuesday 20 February 2001 13:56, Tim Cook wrote:
Donald Braman wrote:
Works! One million thanks! Is that documented anywhere? -Don
I think it's because you used the assignment operator '=' instead of the comparison operator '=='.
Probably in the ZQR, and other places.
More likely in the Python documentation, since expr="" is Python-land stuff. Have a better one, Curtis Maloney.
Curtis Maloney wrote:
Probably in the ZQR, and other places.
More likely in the Python documentation, since expr="" is Python-land stuff.
Quite true. I also noticed that Chris pointed out where I misspoke. I find "Python Essential Reference", New Riders, ISBN:0-7357-0901-7 particularly useful. -- Tim Cook, President - FreePM,Inc. http://www.FreePM.com Office: (901) 884-4126 New MedicationManager, Try it now at: http://www.freepm.org:8080/FreePM
It worked brilliantly untill I changed my data type from text to bool. Now it evaluates, but never as true. My expression is: <dtml-if expr="bool_column == 't'">It is true</dtml-if> I've also tried expr="bool_column is true", "bool_column = 't'", "bool_column == 'true'", etc. I've found the Python documentation on basic types and their operations, but still can't figure out what I'm doing wrong. Don -----Original Message----- From: tim@mr4.its.yale.edu [mailto:tim@mr4.its.yale.edu]On Behalf Of Tim Cook Sent: Tuesday, February 20, 2001 9:20 PM To: Curtis Maloney Cc: donald.braman@yale.edu; zope@zope.org Subject: Re: [Zope] simple question about <!--#if expr="fieldname = 't'"--> Curtis Maloney wrote:
Probably in the ZQR, and other places.
More likely in the Python documentation, since expr="" is Python-land stuff.
Quite true. I also noticed that Chris pointed out where I misspoke. I find "Python Essential Reference", New Riders, ISBN:0-7357-0901-7 particularly useful. -- Tim Cook, President - FreePM,Inc. http://www.FreePM.com Office: (901) 884-4126 New MedicationManager, Try it now at: http://www.freepm.org:8080/FreePM
Donald Braman wrote:
It worked brilliantly untill I changed my data type from text to bool. Now it evaluates, but never as true.
My expression is: <dtml-if expr="bool_column == 't'">It is true</dtml-if> I've also tried expr="bool_column is true", "bool_column = 't'", "bool_column == 'true'", etc.
I've found the Python documentation on basic types and their operations, but still can't figure out what I'm doing wrong.
Boolean expressions that evaluate as false are: 0 (zero), None and empty strings, lists, tuples and dictionaries. So your string is always true. "bool_column == ''" or "bool_column == 0 " will eval false. -- Tim Cook, President - FreePM,Inc. http://www.FreePM.com Office: (901) 884-4126 New MedicationManager, Try it now at: http://www.freepm.org:8080/FreePM
nice. thanks. -----Original Message----- From: Chris Withers [mailto:chrisw@nipltd.com] Sent: Wednesday, February 21, 2001 11:03 AM To: tim@freepm.org Cc: donald.braman@yale.edu; Curtis Maloney; zope@zope.org Subject: Re: [Zope] Python 101 Tim Cook wrote:
My expression is: <dtml-if expr="bool_column == 't'">It is
true</dtml-if> Much simpler: <dtml-if bool_column>It is true</dtml-if> cheers, Chris
Tim Cook wrote:
misspoke. I find "Python Essential Reference", New Riders, ISBN:0-7357-0901-7 particularly useful.
Yup, that book rocks :-) I see New Riders have been wise enough to take up the Zope book deal too... cool... Chris
I'm currently awaiting Python Essential Reference delivery. :-) But I'm impatient! -Don -----Original Message----- From: Chris Withers [mailto:chrisw@nipltd.com] Sent: Wednesday, February 21, 2001 9:40 AM To: tim@freepm.org Cc: Curtis Maloney; donald.braman@yale.edu; zope@zope.org Subject: Re: [Zope] simple question about <!--#if expr="fieldname = 't'"--> Tim Cook wrote:
misspoke. I find "Python Essential Reference", New Riders, ISBN:0-7357-0901-7 particularly useful.
Yup, that book rocks :-) I see New Riders have been wise enough to take up the Zope book deal too... cool... Chris
With Tim's advice, I can get it to work for a single if expression, I can't get it to work for more than one...and I need NINE! Any idea what I can do? Here's the code again (I didn't change it to nice generic names this time). <!--#in rankingquery--> <tr> <td>Score</td> <td><!--#var citation--><!--#var year--></td> <td><!--#var casenameshort--></td> <td><!--#if expr="currie=='t'"-->Currie<!--#/if></td> <td><!--#if expr="farber=='t'"-->Farber<!--#/if></td> <td><!--#if expr="fisher=='t'"-->Fisher<!--#/if></td> <td><!--#if expr="gunther=='t'"-->Gunther<!--#/if></td> <td><!--#if expr="landmark=='t'"-->Landmark<!--#/if></td> <td><!--#if expr="lockhart=='t'"-->Lockhart<!--#/if></td> <td><!--#if expr="oxford=='t'"-->Oxford<!--#/if></td> <td><!--#if expr="schwartz=='t'"-->Schwartz<!--#/if></td> <td><!--#if expr="stone=='t'"-->Stone<!--#/if></td> </tr> <!--#/in--> And the error I get this time is: unexpected end tag, for tag <!--#/if></td> <td><!--#if expr="fisher=='t'"-->, on line 83 of index_html Traceback (innermost last): File /usr/local/zope/230/lib/python/ZPublisher/Publish.py, line 222, in publish_module File /usr/local/zope/230/lib/python/ZPublisher/Publish.py, line 187, in publish File /usr/local/zope/230/lib/python/Zope/__init__.py, line 221, in zpublisher_exception_hook (Object: index_html) File /usr/local/zope/230/lib/python/ZPublisher/Publish.py, line 171, in publish File /usr/local/zope/230/lib/python/ZPublisher/mapply.py, line 160, in mapply (Object: manage_edit) File /usr/local/zope/230/lib/python/ZPublisher/Publish.py, line 112, in call_object (Object: manage_edit) File /usr/local/zope/230/lib/python/OFS/DTMLDocument.py, line 144, in manage_edit (Object: index_html) File /usr/local/zope/230/lib/python/DocumentTemplate/DT_String.py, line 388, in munge (Object: index_html) File /usr/local/zope/230/lib/python/DocumentTemplate/DT_String.py, line 408, in cook (Object: index_html) File /usr/local/zope/230/lib/python/DocumentTemplate/DT_String.py, line 242, in parse (Object: index_html) File /usr/local/zope/230/lib/python/DocumentTemplate/DT_String.py, line 281, in parse_block (Object: index_html) File /usr/local/zope/230/lib/python/DocumentTemplate/DT_String.py, line 131, in parse_error (Object: index_html) Document Template Parse Error: (see above) Any help appreciated. -Don -----Original Message----- From: tim@mr1.its.yale.edu [mailto:tim@mr1.its.yale.edu]On Behalf Of Tim Cook Sent: Monday, February 19, 2001 9:38 PM To: donald.braman@yale.edu Cc: zope@zope.org Subject: Re: [Zope] simple question about <!--#if expr="fieldname = 't'"--> Donald Braman wrote:
I'm having trouble making a simple text comparison (my very first in Zope).
<td><!--#if expr="fieldname = 't'"-->yes<!--else-->no<!--#/if></td>
(Object: fieldname = 't') SyntaxError: (see above)
I think it's because you used the assignment operator '=' instead of the comparison operator '=='. -- Tim Cook, President - FreePM,Inc. http://www.FreePM.com Office: (901) 884-4126 New MedicationManager, Try it now at: http://www.freepm.org:8080/FreePM
On Mon, 19 Feb 2001 22:15:39 -0500 Donald Braman <donald.braman@yale.edu> wrote:
With Tim's advice, I can get it to work for a single if expression, I can't get it to work for more than one...and I need NINE! Any idea what I can do? Here's the code again (I didn't change it to nice generic names this time).
<!--#in rankingquery--> <tr> <td>Score</td> <td><!--#var citation--><!--#var year--></td> <td><!--#var casenameshort--></td> <td><!--#if expr="currie=='t'"-->Currie<!--#/if></td> <td><!--#if expr="farber=='t'"-->Farber<!--#/if></td> <td><!--#if expr="fisher=='t'"-->Fisher<!--#/if></td> <td><!--#if expr="gunther=='t'"-->Gunther<!--#/if></td> <td><!--#if expr="landmark=='t'"-->Landmark<!--#/if></td> <td><!--#if expr="lockhart=='t'"-->Lockhart<!--#/if></td> <td><!--#if expr="oxford=='t'"-->Oxford<!--#/if></td> <td><!--#if expr="schwartz=='t'"-->Schwartz<!--#/if></td> <td><!--#if expr="stone=='t'"-->Stone<!--#/if></td> </tr> <!--#/in-->
And the error I get this time is:
unexpected end tag, for tag <!--#/if></td> <td><!--#if expr="fisher=='t'"-->, on line 83 of index_html
Transform your closing dtml tags to the form <!--#/if--> or better yet, ditch the ugly html comment form entirely and go for <dtml-if> </dtml-if>. You might like to give Shane Hathaway's ZDebug product a go, as well, as it makes DTML error diagnosis much easier. http://www.zope.org/Members/hathawsh/ZDebug John
Donald Braman wrote:
And the error I get this time is:
unexpected end tag, for tag <!--#/if></td> <td><!--#if expr="fisher=='t'"-->, on line 83 of index_html
I think John hit on this one. Just to interject though; if that doesn't fix it look at your other tag nesting. Quite often (for me anyway) I find where I have an enclosing tag set messed up, especially when you get the 'unexpected end tag' error. You may find you have an open -let or -with etc. HTH, -- Tim Cook, President - FreePM,Inc. http://www.FreePM.com Office: (901) 884-4126 New MedicationManager, Try it now at: http://www.freepm.org:8080/FreePM
participants (5)
-
Chris Withers -
Curtis Maloney -
Donald Braman -
John Morton -
Tim Cook