[Zope] Argument passing and DTMLFile methods

Terry Hancock hancock@anansispaceworks.com
Mon, 01 Jul 2002 03:10:25 -0700


Dieter Maurer wrote:
> Maybe, you should state concisely from what context you want to
> pass parameters to DTMLFile methods:
> 
>   DTMLFile objects behave identically in this respect to
>   DTML methods!

My problem is that they don't -- I've tested the
same code both ways, and it works with "DTML Methods" but
breaks with "DTMLFile Methods".  If indeed they were the
same, then I'd be using:

[your 2nd case]
>     *  When called from DTML or Page Templates, "None"
>        is passed as "client" and a DTML namespace as "REQUEST".

This is what I was originally doing, i.e. the second step in:

Web Request --> DTML Method #1 --> DTML Method #2
                               ^^^

If this call is of either the explicit form:

# -- Contents of "method1.dtml" - explicit version
<dtml-let key1=val1 key2=val2>
	<dtml-var expr="method2(_.None, _)">
</dtml-let>

or the implicit form:

# -- Contents of "method1.dtml" - implicit version
<dtml-let key1=val1 key2=val2>
	<dtml-var method2>
</dtml-let>

then I can happily use key1 and key2 inside Method #2 --
it inherits #1's namespace.  In fact, these two calls
are exactly equivalent.

NOW -- just save the contents of Methods #1 and #2 into
files, and load them as either class or instance methods of
a Zope object created in a product (I spelled this step out
in my last post, so I'll omit it here), and try the same
thing:

Web Request --> DTMLFile Method #1 --> DTMLFile Method #2
                                   ^^^

In this case, the "implicit" call works, but the "explicit"
call breaks. In other words, an implicit call is NO LONGER
EQUIVALENT to an explicit one passing "_.None, _". (This
manifests as a KeyError traceback on key1 or key2 if used
in Method#2).

If they "should" act the same way, then "I've Found a Bug"(TM)!
In which case, I'm collecting information to file a
bug report as concisely as possible.

If not, then I just don't understand the distinctions
between "DTMLFile Methods" and "DTML Methods".

Naturally, I can recode to use the implicit case (in
fact, I've already done this for my particular project),
but it seems like there must be an equivalent explicit
call.

Sorry about the length -- I actually am trying to be
"concise" :-), I just can't think of a way to put this
any more directly.

Thanks,
Terry

-- 
------------------------------------------------------
Terry Hancock
hancock@anansispaceworks.com       
Anansi Spaceworks                 
http://www.anansispaceworks.com 
P.O. Box 60583                     
Pasadena, CA 91116-6583
------------------------------------------------------