You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Recently, I've struggled a bit to find a way to initialize an object at application level and use it at request level.
Following an answer to the same question on SO, I finally used web.config.
It looks like this:
class Foo:
def GET(self):
bar = web.config.bar
r = bar.something()
return r
if __name__ == "__main__":
web.config.bar = Bar()
app = web.application(urls, globals())
app.run()
I don't know if it the right way to do it. Nevertheless, IMHO, this use case should be documented in the very usefull "cookbook" section. And web.config should be documented in "API Reference" section.
The text was updated successfully, but these errors were encountered:
Recently, I've struggled a bit to find a way to initialize an object at application level and use it at request level.
Following an answer to the same question on SO, I finally used
web.config
.It looks like this:
I don't know if it the right way to do it. Nevertheless, IMHO, this use case should be documented in the very usefull "cookbook" section. And
web.config
should be documented in "API Reference" section.The text was updated successfully, but these errors were encountered: