There are three basic strategies for this:
* Just use a global variable (or class attribute). This has well-known drawbacks, but if you can live with them it's very easy to do.
* Attach it to the Application object. You can either use an extra attribute on the Application object itself as Lorenzo suggested, or add it to the settings dictionary by passing extra keyword arguments to the Application constructor. This is a little cleaner than the global variable option, especially if you create a separate Application object for each test.
* Store it in the URLSpec. This would let each handler (or even different instances of the same handler) have their own values for this variable. To do this, define an initialize method in your handler:
def initialize(self, foo):
self.foo = foo
and then pass a dictionary when configuring your urls:
('/somewhere', MyHandler, dict(foo=my_foo))