A little bit of legacy DTML fun here... Zope 2.9.3 On save of a DTML Method, why would this dtml-call fail: <dtml-let standards="REQUEST.SESSION"> <dtml-call "standards.set('AR-DA-08', AR-DA-08)"> </dtml-let> With the error: "Expression (Python) Syntax error: invalid token" Whereas this works fine: <dtml-let standards="REQUEST.SESSION"> <dtml-call "standards.set('AR-DA-07', AR-DA-07)"> </dtml-let> Any insight is appreciated. -- Harlow Pinson Indepth Learning Email: hpinson@indepthl.com Phone: 505 994-2135 Fax: 505 994-3603
hpinson@indepthl.com schrieb:
A little bit of legacy DTML fun here... Zope 2.9.3
On save of a DTML Method, why would this dtml-call fail:
<dtml-let standards="REQUEST.SESSION"> <dtml-call "standards.set('AR-DA-08', AR-DA-08)"> </dtml-let>
With the error:
"Expression (Python) Syntax error: invalid token"
Whereas this works fine:
<dtml-let standards="REQUEST.SESSION"> <dtml-call "standards.set('AR-DA-07', AR-DA-07)"> </dtml-let>
I doubt any of that really "works". So you happen to have the variables named "AR" and "DA" defined as numerical values somewhere? Otherwise the expression makes no sense at all. The leading 0 in 08 and 07 indicates you might have a completely other illusion on what's going on. Any reason you cannot write in a python script something like: REQUEST.SESSION.set('some_resonable_named_variable','AR-DA-07') ? Could you explain in plain english what your final goal of your construction is? Regards Tino Wildenhain
+-------[ Tino Wildenhain ]---------------------- | hpinson@indepthl.com schrieb: | >A little bit of legacy DTML fun here... Zope 2.9.3 | > | >On save of a DTML Method, why would this dtml-call fail: | > | ><dtml-let standards="REQUEST.SESSION"> | > <dtml-call "standards.set('AR-DA-08', AR-DA-08)"> | ></dtml-let> | > | >With the error: | > | >"Expression (Python) Syntax error: invalid token" | > | >Whereas this works fine: | > | ><dtml-let standards="REQUEST.SESSION"> | > <dtml-call "standards.set('AR-DA-07', AR-DA-07)"> | ></dtml-let> | > | I doubt any of that really "works". So you happen | to have the variables named "AR" and "DA" defined | as numerical values somewhere? Otherwise the expression | makes no sense at all. The leading 0 in 08 and 07 indicates | you might have a completely other illusion on what's going on. Apart from all of that; A leading 0 indicates an octal number. 08 is not a valid octal number, but, I'll just agree with Tino here, I don't think you know what you're trying to do. I don't think you want.. AR minus DA minus 8 as the value. -- Andrew Milton akm@theinternet.com.au
Hi Tino. Yes, that is correct. This application has variables named like: 'AR-DA-08' This also fails in a Page Template: <span tal:define="standards python: request.SESSION"> <tal:block define="temp python: data.set('AR-DA-08',AR-DA- 08)"></tal:block> </span> With the error: Compilation failed TAL.TALDefs.TALError: Python expression error: invalid token (Python expression "data.set('AR-DA-08',AR-DA-08)", line 1) in expression "python: data.set('AR Yet this works: <span tal:define="standards python: request.SESSION"> <tal:block define="temp python: data.set('AR-DA-07',AR-DA- 07)"></tal:block> </span> So you are saying the interpreter is seeing the '-' as a minus? Why would it work in one case and not the other? Could the minus be escaped somehow? -- Harlow Pinson Indepth Learning Email: hpinson@indepthl.com Phone: 505 994-2135 Fax: 505 994-3603
----- Original Message ----- From: <hpinson@indepthl.com> To: <zope@zope.org> Sent: Tuesday, October 24, 2006 1:04 PM Subject: Re: [Zope] DTML Call Fails
Hi Tino. Yes, that is correct. This application has variables named like:
'AR-DA-08'
This also fails in a Page Template:
<span tal:define="standards python: request.SESSION"> <tal:block define="temp python: data.set('AR-DA-08',AR-DA- 08)"></tal:block> </span>
With the error:
Compilation failed TAL.TALDefs.TALError: Python expression error: invalid token (Python expression "data.set('AR-DA-08',AR-DA-08)", line 1) in expression "python: data.set('AR
Yet this works:
<span tal:define="standards python: request.SESSION"> <tal:block define="temp python: data.set('AR-DA-07',AR-DA- 07)"></tal:block> </span>
So you are saying the interpreter is seeing the '-' as a minus? Why would it work in one case and not the other?
Two possibilities that I can think of: 1) you have a variable called AR-DA-08 and do not have a variable called AR-DA-07 2) you have a variable called AR (and possibly another variable called DA), which when evaluated as a mathematical expression (AR minus DA - 08) provides a result, but when 07 is subtracted, an invalid result is obtained. But, as others have noted, this does not appear to be what you are looking to accomplish! Jonathan
hpinson@indepthl.com schrieb:
Hi Tino. Yes, that is correct. This application has variables named like:
'AR-DA-08'
Not very clever.
This also fails in a Page Template:
<span tal:define="standards python: request.SESSION"> <tal:block define="temp python: data.set('AR-DA-08',AR-DA- 08)"></tal:block>
you still have to quote if you mean the variable with that weird name. Otherwise its an expression in python. _['AR-DA-08'] could work in DTML... but lets better forget that ;) Where does your variable live? In Request maybe?
</span>
With the error:
Compilation failed TAL.TALDefs.TALError: Python expression error: invalid token (Python expression "data.set('AR-DA-08',AR-DA-08)", line 1) in expression "python: data.set('AR
TAL??
Yet this works:
<span tal:define="standards python: request.SESSION"> <tal:block define="temp python: data.set('AR-DA-07',AR-DA- 07)"></tal:block> </span>
So you are saying the interpreter is seeing the '-' as a minus? Why would it work in one case and not the other?
See Andrew's note on ocal numbers.
Could the minus be escaped somehow?
No, but see above. Could you please escape the horribly code + template mixing with DTML? ;) See the zope book for python scripts. (After all in DTML "expressions" its already python code, so why not write just python code and skip all that <foo> stuff around it you dont need anyway? Regards Tino Wildenhain
Changing the dash to an underscore in the variable name solved the problem. -- Harlow Pinson Indepth Learning Email: hpinson@indepthl.com Phone: 505 994-2135 Fax: 505 994-3603
hpinson@indepthl.com schrieb:
Changing the dash to an underscore in the variable name solved the problem.
I'm quite sure you could solve it even better - if we would know where these variables come from and what their meaning is. I suspect some kind of form? Regards Tino Wildenhain
En/na hpinson@indepthl.com ha escrit:
A little bit of legacy DTML fun here... Zope 2.9.3
On save of a DTML Method, why would this dtml-call fail:
<dtml-let standards="REQUEST.SESSION"> <dtml-call "standards.set('AR-DA-08', AR-DA-08)"> </dtml-let>
AR - DA - 08 ^ octal literal HTH
hpinson@indepthl.com wrote:
A little bit of legacy DTML fun here... Zope 2.9.3
On save of a DTML Method, why would this dtml-call fail:
<dtml-let standards="REQUEST.SESSION"> <dtml-call "standards.set('AR-DA-08', AR-DA-08)"> </dtml-let>
With the error:
"Expression (Python) Syntax error: invalid token"
Whereas this works fine:
<dtml-let standards="REQUEST.SESSION"> <dtml-call "standards.set('AR-DA-07', AR-DA-07)"> </dtml-let>
Any insight is appreciated.
hpinson, Maybe you can get away with something like _['AR-DA-07'] or maybe _.getitem('AR_DA-07')? David
Yep, changing to a underscore from a dash does the trick. Thanks to everyone who helped me understand this. -- Harlow Pinson Indepth Learning Email: hpinson@indepthl.com Phone: 505 994-2135 Fax: 505 994-3603
participants (6)
-
Alexis Roda -
Andrew Milton -
David H -
hpinson@indepthl.com -
Jonathan -
Tino Wildenhain