A WSGIApplication instance records the value of the debug
parameter as self.__debug
: the double underscore is a strong indication that no code outside the class itself is supposed to look at this attribute, as it's considered an internal application detail and could change "at any time" (even in a minor revision of the API). If you want to ignore this extremely strong indication, you could, technically, use webapp.WSGIApplication.active_instance._WSGIApplication__debug
to look at it, but it's a truly bad idea.
A much better idea is to subclass WSGIApplication
in your own code to make the attribute publically visible:
class MyWSGIapp(webapp.WSGIApplication):
def __init__(self, url_mapping, debug=False):
self.debugmode = debug
webapp.WSGIApplication.__init__(self, url_mapping, debug)
Now, when you use MyWSGIapp
instead of webapp.WSGIApplication
to start things off, webapp.WSGIApplication.active_instance.debugmode
becomes a clean, solid way to access the attribute of interest from wherever else in your application.