Webob "request" objects are semi-ephemeral in the context of WSGI. Pyramid 
creates one while processing, and if you're using pyramid_retry then it'll make 
a new one for each attempt. The "environ", however, is one-per WSGI request and 
state you put in there will survive for the entire WSGI lifecycle and can be 
shared with middleware etc that is not Pyramid.

The recommendation is to almost always store data on the request unless you 
have a really good reason not to.

- Michael

> On Nov 12, 2020, at 14:10, 'Jonathan Vanasco' via pylons-discuss 
> <[email protected]> wrote:
> 
> I don't know about "correct", but I use `add_request_method` to attach a 
> custom object(s) with `reify=True,` and then store all the information in 
> those objects.  IIRC, the narrative documentation and tutorials use it for 
> similar purposes.
> 
> https://docs.pylonsproject.org/projects/pyramid/en/latest/api/config.html#pyramid.config.Configurator.add_request_method
> 
> 
> On Thursday, November 12, 2020 at 8:57:58 AM UTC-5 [email protected] wrote:
> Hi,
> When we have to store custom information about current request, we can use 
> it's properties, attributes or environment (or even annotations).
> What is the correct usage of each of them, and is there any benefit of using 
> one of them against the others?
> 
> Best regards,
> Thierry
> -- 
>   https://www.ulthar.net <https://www.ulthar.net/> -- 
> http://pyams.readthedocs.io <http://pyams.readthedocs.io/>
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] 
> <mailto:[email protected]>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/pylons-discuss/344da45e-9eef-436a-9eb9-66e40dda0e56n%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/pylons-discuss/344da45e-9eef-436a-9eb9-66e40dda0e56n%40googlegroups.com?utm_medium=email&utm_source=footer>.

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/47DF611C-D487-4AED-80BA-47F75A1888A4%40gmail.com.

Reply via email to