[Zope] External method default arg weirdness

Paul Winkler slinkp23@yahoo.com
Thu, 10 May 2001 15:26:06 -0400


Dieter Maurer wrote:
> 
> Paul Winkler writes:
>  > But I don't understand why that affects the rest of the
>  > parameters??? Very un-pythonic.

> I agree. The more modern Python scripts solve the same problem
> much better.
> 
> The motivation for this "feature":
> 
>   Often External Methods should behave like methods.
>   Sometimes, they should not.
> 
>   The implementers used the following heuristics to distinguish
>   between these two cases:
> 
>     First, it is tried to call the method with the parameters
>     provided. If this raises a "TypeError" and the
>     first parameter is called "self", then the
>     call is retried, this time with "aq_parent" as first
>     parameter.
> 
>   This magic works only, if the method is called with
>   precisely one parameter less then the required
>   arguments. It breaks very likely, when there are
>   default parameters. In this case, you need to pass
>   the "self" parameter explicitly and can not count on
>   the magic.

Thanks for the clarification. Now I see why it's done that way,
but I still think it's a pretty dodgy solution - it's like,
"Here you can write python code that will behave like you expect
it to, but it will fail under certain obscure circumstances, and
when it breaks the traceback error will not help you."  Too much
magic hand-waving for me.

I'll try python scripts, see if that's better.

-- 
...................    paul winkler   ....................
custom calendars & printing: http://www.calendargalaxy.com
       A member of ARMS:   http://www.reacharms.com
            home page:  http://www.slinkp.com