[Zope-dev] dtml-call problem

Duncan Booth duncan@rcp.co.uk
Thu, 6 Apr 2000 11:47:24 +0000


> Hi,
> 
> I think there is a problem in Zope:
> 
> I have 3 methods:
> 
> method_a: 	<dtml-call "method_b">
> method_b: 	<dtml-call "method_c">
> method_c: 	<dtml-return "_.int(1)">
> 
> I can call method_a without problems. But if I change it from 
> 	<dtml-call "method_b">
> to
> 	<dtml-call "method_b()">            (look at the braces!)
> I get an error message. I think this is an error in Zope. Can anybody
> verify this?! 

This should be in an FAQ somewhere.

When you call a DTML method, the first two parameters passed in 
are the object on which the method is to operate (which can 
usually be '_.None'), and the acquisition namespace '_'.

If you call method_b with no parameters at all, the current 
environment is not available to it, and in particular it cannot find 
method_c because it has nowhere to look for it.

Try:
	<dtml-call "method_b(_.None, _)"> 
and everything should be fine.

See also http://www.zope.org/Documentation/Guides/DTML-
HTML/DTML.5.6.2.html which explains exactly what these 
arguments are, although not how to use them.
Actually having read this, it looks (I haven't checked it) as though 
you should also be able to write:
	<dtml-call "method_b(mapping=_)"> 
which is arguably more readable.

-- 
Duncan Booth                                             duncan@dales.rmplc.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?
http://dales.rmplc.co.uk/Duncan