Hi, I have a folder with an index_html that calls subfolder/methodA. methodA in turn calls subfolder/methodB. This fails miserably with a NameError. I've tried the following variants for the calls: In subfolder/methodA: 1.<dtml-if "methodB"> 2.<dtml-if "methodB()"> The above fail with NameError:methodA 3.<dtml-if "subfolder.methodB"> 4.<dtml-if "subfolder.methodB()"> These fail with NameError:subfolder What is the proper syntax? I'm also using methodB in a dtml-in tag. Andres Corrada
I have a folder with an index_html that calls subfolder/methodA. methodA in turn calls subfolder/methodB. This fails miserably with a NameError. I've tried the following variants for the calls:
In subfolder/methodA:
1.<dtml-if "methodB"> 2.<dtml-if "methodB()">
The above fail with NameError:methodA
3.<dtml-if "subfolder.methodB"> 4.<dtml-if "subfolder.methodB()">
These fail with NameError:subfolder
I have seen this rather too often and was hoping that it'd been fixed in 2.1 (we are still using 2.0) I think I can describe it more specifically as I've run into it often enough: You will in essence loose all but the most immediate namespace in a call to a method that's made via an evaluated expression. You should *not* see the problem if you evaluate it as <dtml-var methodB> *so long as methodA was not called as an expression* (i.e. not called as <dtml-var "methodA"> but rather <dtml-var methodA>. The obvious problem here is that you can't explicitly pass named parameters to your methods 'cause the second you do so you give up all the surrounding namespace. You can get around it with <dtml-let> stuff, but sometimes that's just not the best way. There is a related problem with permissions going away as well. I think I've seen this when attempting to evaluate a method indirectly, as in <dtml-var "_.getitem(methodNameInHere,0)(var=someValue)"> you'll get whatever's in methodNameInHere to execute, but you'll have lost all your permissions. (I'm not sure I'm entirely accurate on this - I ran into it yesterday but I had done so many iterations on the theme that they all blur together - I'm close on this though). IMHO this is a really *bad* problem that should be fixed asap - it has denied me opportunities for some really decent abstraction countless times. Anyone else? If someone would like I'll cook up a proper demonstration of this.
Dave Parker wrote:
IMHO this is a really *bad* problem that should be fixed asap - it has denied me opportunities for some really decent abstraction countless times.
Anyone else? If someone would like I'll cook up a proper demonstration of this.
Thank you so much for your detailed explanation of the problem, Dave. I guess I should mention that I got around the problem by putting moving "subfolder/methodA" into the folder of the calling DTML document, thus allowing me to write "<dtml-if "subfolder.methodB()">" within "mainfolder/methodA". As you mentioned, this "pollutes" the "mainfolder" with methods that should really be in "subfolder". Again, thank you for your thoughts on this problem. ------------------------------------------------------ Andres Corrada-Emmanuel Email: andres@corrada.com Owner http://www.corrada.com/mamey Mamey Phone: (413) 587-9595 ------------------------------------------------------
Andres Corrada wrote:
Dave Parker wrote:
IMHO this is a really *bad* problem that should be fixed asap - it has denied me opportunities for some really decent abstraction countless times.
Thank you so much for your detailed explanation of the problem, Dave. I guess I should mention that I got around the problem by putting moving "subfolder/methodA" into the folder of the calling DTML document, thus allowing me to write "<dtml-if "subfolder.methodB()">" within "mainfolder/methodA". As you mentioned, this "pollutes" the "mainfolder" with methods that should really be in "subfolder". Again, thank you for your thoughts on this problem.
My pleasure. I just wish it'd get fixed - it's stopped me cold a dozen times and I've ended up doing some just plain ugly workarounds (sounds like you are now familliar with them ;). Sadly, I just don't have the time (and probably the knowledge ;) to look into it further myself.
participants (3)
-
andres -
Andres Corrada -
Dave Parker