My app uses a data service that requires periodically requesting an access_token using my apps credentials given by the data service provider. I send this token in the header of every request my app sends to the data service, and I only know the token has expired when a request comes back with a certain 403 response. At this point my app needs to request a new access_token and the cycle continues.
So every instance of my app needs to use the current access_token, and the first instance which receives a 403 response needs to update the access token for all instances. So I have a couple of questions: 1. At first I tried putting the shared access_token variable in a model file, but I found that the view would always see access_token as defined in the model file even if I tried declaring it global and changing it in a controller (I guess model files are reloaded every action?), so instead I defined db.access_token in the model and that worked. I can now change db.access_token in a controller and see the change in the view. But is this the proper way to share a variable across application instances? 2. Is there a way to make a thread-safe function in my application so that every request to the data service requires access to some kind of Lock object in order to be sure that if a 403 comes back a new access_token can be obtained and assigned to db.access_token before another instance gets a 403 response? Thank you very much in advance. Please note: I am fairly new to databases and web frameworks in general (my Python is 'ok') so if you find yourself confused by my question - think newbie. Scruffy -- 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.