Phil Harris writes:
> Wouldn't it be better to pass in self?
> As in:
> def my_method(self,REQUEST=None):
> '''my_method interpreting *REQUEST*.form.'''
> if REQUEST is None:
> REQUEST=self.REQUEST # safety_valve in case you forget to pass in
> form= REQUEST.form # this is a dictionary containing form
> # variables and associated values
I would pass in "self" only if I need it (to access Zope objects
in the method).
I can trust ZPublisher that it will pass REQUEST.
Thus, there is no danger to forget passing REQUEST in this case.
And if I call the method directly from DTML, the danger
to forget passing "this()" (to be passed to 'self') is
as great as to forget passing "REQUEST". Just, that
"this()" is more nasty than "REQUEST" (requires more Zen).
Really knowledgable people can use:
and then call it in DTML by
This will work, as an external method passes the folder containing
the method as the first argument, provided that
1. the first argument is called "self"
2. the method is called with precisely one argument less
than the number of defined arguments.
The above "dtml-call" will result in "my_method()".
Therefore, both rules are satisfied.
However, should we really propose this?
I tend to favour the following rule:
Whenever you call an external method from DTML,
*ALWAYS* pass all parameters explicitely.
Zope maillist - [EMAIL PROTECTED]
** No cross posts or HTML encoding! **
(Related lists -