[Zope] Zope context

DA Loeffler David.Loeffler@bristol.ac.uk
Mon, 5 Aug 2002 17:09:55 +0100 (BST)


On Mon, 5 Aug 2002, Chris Withers wrote:

> 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
> 
> Ouch! Bad! Pain! Don't!
> [...]
> This is distinctly dodgy and probably work more by luck than design :-S
> 

OK, so how else do I do it? The problem is that I am trying to create a
class whose instances will be ephemeral, lasting only for one
transaction, but which can call objects within the ZODB. Essentially my
classes are glorified Pluggable Brains, but they have to combine data
from several database queries, which are of course all Z SQL methods.
The data cannot be passed as class initialisation parameters as the
class needs to decide what calls to make depending on the data from
other queries.

David