I would like to store some information at the “request scope” when using google app engine (python). What I mean by this is that I would like to initialize some information when a request is first received, and then be able to access it from anywhere for the life of the request (and only from that request).
An example of this would be if I saved the current user’s name at request scope after they were authenticated.
How would I go about doing this sort of thing?
Thanks!
A pattern used in app engine itself seems to be
threading.localwhich you can grep for in the SDK code. Making os.environ request local is done like that inruntime/request_environment.pyfor example.A rough example:
From elsewhere you could authenticate early on in handler code.
and provide convenience that can be used in other parts of your code