It should be OK. The only potential issue is if the framework adds 
request.some_stuff in the future -- then your app code would be overwriting 
an attribute used by the framework (unlikely to be an issue if you avoid 
generic names).

Anthony

On Friday, September 15, 2017 at 1:10:06 AM UTC-4, Brendan Barnwell wrote:
>
> Is it considered kosher for controller functions to add their own custom 
> data to the request object?  I didn't see anything in the docs about this.  
> For instance if a controller wants to do request.some_stuff = 123, is that 
> "allowed"?
>
> The reason for this is that I have some library functions called by 
> controllers that may need access to information that could be in the 
> request, or they can fall back to a default.  I would prefer not to make 
> these library functions accept this extra information as a parameter, but 
> rather have them look to see if it is available in the current request, and 
> use it if so, otherwise fall back to the default.  This information would 
> not normally be available on the request object, but is derived from 
> request.args, so the controller function could store this "processed" 
> version of args on the request object for use by other functions later.  (I 
> don't want to store it in session because it really is supposed to be 
> request-local and shouldn't persist from one request to another.)
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to