DA Loeffler wrote:
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.
FWIW i also do this and dont have any problems. i think the important point here is that these classes are not persistent; they (or rather instances of them) are constructed with each request, do their stuff and are thrown away.
David
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )