Assigning strings using DTML-LET
I'm trying to assign the string: 1=1 to the variable criteria using this construct: <dtml-let criteria='1=1'> but I can't because Zope complains: invalid parameter: "=1'", for tag <dtml-let criteria='1=1'>, on line 5 of Create_List Some playing around reveals that it doesn't like spaces and the equals sign (=) in the string. Am I correct in thinking that something delimited by single quotes (eg. 'this is a string') is a string? If so why can't I (or how can I) include spaces and the equal sign inside the string. thanks - Jason Wong
From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Jason Wong Sent: Friday, March 31, 2000 12:35 PM To: Send Zope Mailing List Subject: [Zope] Assigning strings using DTML-LET
I'm trying to assign the string:
1=1
to the variable criteria using this construct:
<dtml-let criteria='1=1'>
but I can't because Zope complains:
Unlike other tags, the dtml-let tag is quote-sensitive, requiring that attribute values are quoted. So in the above code, you're trying to evaluate the expression "1=1", which isn't valid Python code (you're trying to assign a value to a value). What you want is: <dtml-let criteria="'1=1'">
thanks - Jason Wong
-- Alexander Staubo / http://alex.mop.no/ "The difference between theory and practice is that, in theory, there is no difference between theory and practice."
Unlike other tags, the dtml-let tag is quote-sensitive, requiring that attribute values are quoted. So in the above code, you're trying to evaluate the expression "1=1", which isn't valid Python code (you're trying to assign a value to a value). What you want is:
<dtml-let criteria="'1=1'">
Thanks. After scouring through all the docs that I can lay my hands on I finally found an implicit reference to the above usage of dtml-let in "HowTo: Advanced DTML techniques". <dtml-gripe> One of the main stumbling blocks in getting to grips with Zope is the incoherent documentation. The information one needs is scattered about in countless docs so a lot of the time will be spent searching those docs. This isn't helped by the fact that the guides and how-to's themselves contain many errors in the examples. </dtml-gripe> But many thanks to the kind people on this list who have responded swiftly to my questions. - Jason Wong
Jason Wong wrote:
I'm trying to assign the string:
1=1
to the variable criteria using this construct:
<dtml-let criteria='1=1'>
but I can't because Zope complains:
invalid parameter: "=1'", for tag <dtml-let criteria='1=1'>, on line 5 of Create_List
Some playing around reveals that it doesn't like spaces and the equals sign (=) in the string.
Am I correct in thinking that something delimited by single quotes (eg. 'this is a string') is a string? If so why can't I (or how can I) include spaces and the equal sign inside the string.
<dtml-let criteria=="'1=1'"> should work. In dtml-let, you write one pair of quotes to specify that your're writing a python expression. Inside quotes you're writing python. Examples of valid python expressions: 'this is a string' 23 methodname You can wrap up any of the above inside a pair of double quotes and then use it in <dtml-let> HTH, Shalabh ______________________________ Shalabh Chaturvedi icq://43284067 http://advogato.org/person/shalabh/
Jason Wong wrote:
I'm trying to assign the string:
1=1
to the variable criteria using this construct:
<dtml-let criteria='1=1'>
but I can't because Zope complains:
invalid parameter: "=1'", for tag <dtml-let criteria='1=1'>, on line 5 of Create_List
Some playing around reveals that it doesn't like spaces and the equals
sign
(=) in the string.
Am I correct in thinking that something delimited by single quotes (eg. 'this is a string') is a string? If so why can't I (or how can I) include spaces and the equal sign inside the string.
thanks - Jason Wong
DTML-LET sintax:<dtml-let variable="exp"> </dtml-let> So use: <dtml-let criteria="'1=1'"> not <dtml-let criteria='1=1'> Or te best way ( I've found it yesterday) : <dtml-let valueVar="'var has value: %s' % (var)"> All the best! Marcel
Jason Wong wrote:
I'm trying to assign the string:
1=1
to the variable criteria using this construct:
<dtml-let criteria='1=1'>
but I can't because Zope complains:
invalid parameter: "=1'", for tag <dtml-let criteria='1=1'>, on line 5 of Create_List
Some playing around reveals that it doesn't like spaces and the equals sign (=) in the string.
Am I correct in thinking that something delimited by single quotes (eg. 'this is a string') is a string? If so why can't I (or how can I) include spaces and the equal sign inside the string.
thanks - Jason Wong
_______________________________________________ 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 )
You should try, instead : <dtml-let criteria="'1=1'"> A string is an expression, and expressions must be enclosed in double-quotes... Regards, P.-J. Grizel
participants (5)
-
Alexander Staubo -
Jason Wong -
Marcel Preda -
Pierre-Julien Grizel -
Shalabh Chaturvedi