Re: [pylons-discuss] Request attributes vs request environment

2020-11-12 Thread Michael Merickel
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 
>  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 tfl...@gmail.com 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  -- 
> 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 pylons-discuss+unsubscr...@googlegroups.com 
> .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/pylons-discuss/344da45e-9eef-436a-9eb9-66e40dda0e56n%40googlegroups.com
>  
> .

-- 
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 pylons-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/47DF611C-D487-4AED-80BA-47F75A1888A4%40gmail.com.


[pylons-discuss] Re: Request attributes vs request environment

2020-11-12 Thread 'Jonathan Vanasco' via pylons-discuss
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 tfl...@gmail.com 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 -- 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 pylons-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/344da45e-9eef-436a-9eb9-66e40dda0e56n%40googlegroups.com.


[pylons-discuss] Request attributes vs request environment

2020-11-12 Thread Thierry Florac
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 -- 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 pylons-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAPX_VWCxE500%2Bkc46J5czPv-7ATAZV7MrXuoqW%2B8c57i1Uy7pw%40mail.gmail.com.