[ZOPE] Newbie: Usage of this(), self, context

Dieter Maurer dieter@handshake.de
Fri, 8 Feb 2002 23:37:24 +0100


c.koll@web.de writes:
 > When I read the Zopebook it seemed to be quite understandable, but loo=
king at some scripts now, I think I somehow mixed it up. What=B4s the dif=
ference between "this()", "self" and "context"? When do I use each one?
"this" is a method of "SimpleItem.SimpleItem". It returns the object.
  It is used in DTML Methods, to access the "client".
  It is also used, to access the nearest acquisition ancestor which
  is a SimpleItem.

"context" is used in a Python Script. It is the object which was
used to access the Python Script.

"self" is often used as the first parameter of an External Method.
In some cases, calling magic automatically passes an object that is equiv=
alent
to "context" for Python Scripts.

Read the corresponding sections in

  <http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html>

for details.
=20

Dieter