[Zope-dev] Recursion

Duncan Booth duncan@rcp.co.uk
Fri, 26 May 2000 15:32:44 +0000


> There would seem to be two ways to 'fix' this, I'll leave it as an exercise
> for the reader to discuss which is best.
> 
> Option 1:
> def foo(self,counter=None):
>     some code
>     if bar == somewhat:
>         self.foo(counter=some_int)
Option 1 has a problem. If you give it a different name in dtml, e.g. 
bar and call it: <dtml-var "bar(counter=5)"> then self is a reference 
to the folder and self.foo doesn't exist. If there is a different method 
'foo' in the folder that other method will be called instead.

> 
> Option 2:
> def foo(self,counter=None):
>     some code
>     if bar == somewhat:
>         foo(self,counter=some_int)
> 
This one should work as advertised. (Unless you redefine foo in the 
python module in which case you get what you deserve).

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