Patrick Gerken wrote:
> Hello,
> 
> I am a bit confused about self.request and self.REQUEST.
> Can anybody point me to an explanation of the different tasks that both 
> have?
> Googling for request vs REQUEST is not helpful...

D'oh! :-)

REQUEST is a Zope2-ism. When you do self.REQUEST somewhere, you are 
actually using acquisition to get this object from the outermost item in 
any (most?) acquisition chain: a magic RequestContainer class whose 
purpose it is to let you acquire a REQUEST.

In general, this is a bit icky. You probably should avoid it.

self.request is not generally available. Rather, it's the most commonly 
used name for the request stored on an attribute in a view or viewlet. 
These are initialised with a context and a request (and view and viewlet 
manager in the case of a viewlet), and normally store those as 
self.context and self.request.

In Zope 2, your views *also* support acquisition, because until Zope 
2.12 at least, they have to in order to have security. So you can do 
self.REQUEST on the view, which acquires it from a parent. But this is 
magic and you shouldn't do it if you can avoid it.

Martin

-- 
Author of `Professional Plone Development`, a book for developers who
want to work with Plone. See http://martinaspeli.net/plone-book

_______________________________________________
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )

Reply via email to