"Phillip J. Eby" wrote:
Try this:
<!--#var standard_html_header--> Depth: <dtml-var "methodA(_.None,_,counter=counter+1)"> <!--#var standard_html_footer-->
Andrew Duncan suggested this one as well more or less as well - thanks. BUT! (read on...)
Horrible workarounds? Not really. Just make sure that if you're going to call any kind of DTML-ish thing with parameters, the first two positional parameters should be _.None and _ so that the current namespace is passed through.
Well, yes they were horrible; minus knowing that to descend more than two levels deep in evaluated method calls I must start passing these things, the workarounds *are* extremely ugly. So I'm glad I have this tidbit in my head now, but I've made a *lot* of compromises since :( And I continue to maintain that this is a *BUG* - here's why: (slightly modified version of the original example - emphasises bug issue) This version blows up: methodA: Depth: <dtml-var counter> <dtml-if "counter < 2"> <dtml-var "methodA(counter=counter+1)"> The error: Error type: KeyError Error value: counter This one works fine: methodA: Depth: <dtml-var counter> <dtml-if "counter < 1"> <dtml-var "methodA(counter=counter+1)"> Output is: Depth: 0 Depth: 1 I strongly believe this is a bug in that if it's the case that my namespace goes away minus passing in the namespace as a parameter, the second example *should not have worked*. It strikes me that someone went to the effort to ensure that namespace gets passed down for me to *some* extent, becuase I'm getting "Depth: 1". That it should fail at the next level appears entirely arbitrary. If this is really really not a bug, then we are going to have a piece of documentation that says: "If you want to call your methods within an expression context where you're calling depth is greater than two, you must pass in the namespace as (_.None,_[,...])" I would personally be embarassed to have such a note in there. Sorry, but this one has frustrated me way too many times. Please tell me why I'm wrong. Thanks, Dave Parker