[Zope-dev] Adding functions to _
Evan Simpson
evan@4-am.com
Mon, 18 Sep 2000 10:28:32 -0400
From: Itamar Shtull-Trauring <itamar@maxnm.com>
> However, when I call the function, I get an error about DocumentTemplate,
> from which I discovered that when I call _.logvis('a_string'), instead of
> the string being passed as the first parameter, _ is passed as the first
> parameter to my function, forcing me to truncate it when calling log2vis:
> Any idea what could cause this strange behaviour? it doesn't happen for
> other functions inserted into _ in DT_Util.py.
When you stuff a function into "d", you're adding it to the class dictionary of DocumentTemplate, so
it effectively becomes a method of that class. The first argument gets treated as "self", just like
in any other class method.
All of the functions in DT_Util are either builtins (which never get turned into bound methods) or
functions with a leading "self" parameter.
Cheers,
Evan @ digicool & 4-am