REQUEST or request

Today I was looking for a way how to set cookies from within Zope programmatically, so I googled and found this site:
https://logbuch.dmaertens.de/zope/cookies-in-zope-und-plone

self.request.response.setCookie(name, value, **options)

Wait... I never saw request in lower case in the Zope environment.

e.g. see the Zope docs...

https://zope.readthedocs.io/en/latest/zdgbook/ObjectPublishing.html#manual-access-to-request-and-response

response=REQUEST.RESPONSE

Or overall in my inherited Zope code base I can read something like this...

REQUEST.RESPONSE.setHeader('content-type', 'text/plain')

Then at Plone docs I found this page:
https://docs.plone.org/develop/plone/sessions/cookies.html#reading-cookies

self.request.cookies.get("cookie_name", "default_value_if_cookie_not_set")

Can anybody shed some light why seemingly Plone uses request and response and Zope uses REQUEST and RESPONSE?

Cheers

jugmac00 via Plone Community wrote at 2019-11-6 18:33 +0000:

...
Today I was looking for a way how to set cookies from within Zope programmatically, so I googled and found this site:
https://logbuch.dmaertens.de/zope/cookies-in-zope-und-plone

self.request.response.setCookie(name, value, **options)

Wait... I never saw request in lower case in the Zope environment.

"request" is the (more modern) spelling which comes from
(Zope 3) BrowserView conventions. Those views typically
use the attributes context and request to access the
adapted objects (views are (under the hood) adapters for an object
and the request).

"REQUEST" is the (older) spelling used to access the request object
via acquisition. Thus, in a BrowserView, you typically
have self.request is self.context.REQUEST.

2 Likes

Thank you, @dieter!

Plone Foundation Code of Conduct