[Zope3-Users] New Request Variable?
Jean-Marc Orliaguet
jmo at ita.chalmers.se
Fri May 19 17:13:05 EDT 2006
Jim Washington wrote:
> I have an expensive function (the result is a long list of IntIds)
> that I only want to call once in a request. It only gets calculated
> the first time it is called, and the results may be used anytime after
> that. But only for the current request. A subsequent request has to
> recalculate from the beginning.
>
> Session is the wrong place to stash this. I do not want want it to
> persist beyond the current request.
>
> Request is also the wrong place. It's slotted; I cannot add variables.
>
> So where is the proper place to hold on to something like this just
> for the duration of one request?
>
> Suggestions (or solutions), anyone? I fear I may have missed
> something obvious.
>
> -Jim Washington
Hi, use request annotations, they're writable:
self.request.annotations['namespace.var'] = var
self.request.annotations.get('namespace.var')
/JM
More information about the Zope3-users
mailing list