[Zope3-Users] How to access "request" variable from vocabulary

Benji York benji at zope.com
Mon Aug 6 13:10:27 EDT 2007


Yow, the whitespace in my last message was seriously messed up.  Let me
try again.

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()

      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