[Zope] Namespace problem

Dave Parker dparker@globalcrossing.com
Wed, 15 Dec 1999 09:43:48 -0600


>         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.