[Zope3-Users] How to access "request" variable from vocabulary
Benji York
benji at zope.com
Mon Aug 6 13:08:33 EDT 2007
Adam Groszer wrote:
> I'm using something like this:
>
> def getCurrentRequest():
> return getInteraction().participations[0]
It is, of course, better if you can structure your app so you don't have
to pull the request "out of thin air", but if you do, I'd be a little
more careful about it. Like so:
def getRequest():
i = zope.security.management.getInteraction() # raises
NoInteraction
for p in i.participations:
if IRequest.providedBy(p):
return p
raise RuntimeError('Could not find current request.')
--
Benji York
Senior Software Engineer
Zope Corporation
More information about the Zope3-users
mailing list