[Zope] Zope context

Bo M. Maryniuck b.maryniuk@forbis.lt
Mon, 5 Aug 2002 17:58:03 +0200


On Monday 05 August 2002 17:42, DA Loeffler wrote:
> I got round this one by actually passing the context to the class
> constructor as an argument, and storing it as self.context with the
> class's __init__ method. You can then freely call things on it, in my
> case
>
> for r in self.context.someSQLMethod():
>
> or whatever. Since python functions are call-by-reference, you can
> even do self.context.manage_addFolder() or whatever, and it will affect
> the context originially passed to it.

It really does not work or probably You just does not understand what I n=
eed=20
(or I not understand You as well). O.K. I'll try again to exaplain.

In Zope product, I do:

class foo:
=09def bar(self):
=09=09return self.context.MyObject()

=2E..and this does not work. O.K., but in the _same_ Zope Product, I just=
 add=20
simple "def" (not within a class), like:

def testHere(self):
=09return self.MyObject()

=2E..and it works. O.K., now how to pass the "context", since all the tim=
e Zope=20
returns me "The variavle 'context' is not defined"? Can You show me a cod=
e a=20
little?

--=20
Sincerely yours, Bogdan M. Maryniuck

Sigh.  I like to think it's just the Linux people who want to be on
the "leading edge" so bad they walk right off the precipice.
(Craig E. Groeschel)