[Zope] RE: Forbidden Variable Names

Dieter Maurer dieter@handshake.de
Fri, 29 Mar 2002 09:06:51 +0100


Ren Bing writes:
 > But the point is the name is "client" but not "id", I know "id" should be
 > avoid of, but who expects "client"? And the most important is that, there's
 > nowhere mentioned "client", and supposely explicitly specified argument or
 > variable should override other thing except reserved keyword of python
 > language, is that right? OK, I checked python documentation, "client" is not
 > a reserved keyword.

The following happens in your case:

  The DTML object's "__call__" is defined by

      def __call__(client=None, REQUEST=None, **kw)

  The ZSQL method wants to call it with itself as client
  (to allow the DTML object to use acquisition) and the provided
  arguments as keywords.
  It probably calls it with something like:

     apply(self.source,(self,),kw)

  and Python raises the exception you saw, because "client" got
  two values.

"client" is mentioned many times -- in the context of DTML objects.
And the body of a Z SQL method is a DTML object.
I do not blame you that you did not recognize this. It is very natural.

On the other hand, it is really difficult to document and catch all
such potential issues.

The best possible solution would be that Z SQL methods would check
for such name clashes and provide a meaningful error message.

Please file a bug report to <http://collector.zope.org>.


Dieter