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.