]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Override initialize() instead of __init__() in RequestHandler subclasses.
authorBen Darnell <ben@bendarnell.com>
Mon, 13 Dec 2010 20:33:25 +0000 (12:33 -0800)
committerBen Darnell <ben@bendarnell.com>
Mon, 13 Dec 2010 20:33:25 +0000 (12:33 -0800)
This is a slight simplification and makes it easier to create further
application-specific subclasses.

Closes #191.

tornado/web.py

index a4eb3f51550c2431d7c3b9c9c5a6f8c8edf3275f..aab8dc19da9392ef525e95da8ce71974fcb741ae 100644 (file)
@@ -1201,8 +1201,7 @@ class HTTPError(Exception):
 
 class ErrorHandler(RequestHandler):
     """Generates an error response with status_code for all requests."""
-    def __init__(self, application, request, status_code):
-        RequestHandler.__init__(self, application, request)
+    def initialize(self, status_code):
         self.set_status(status_code)
 
     def prepare(self):
@@ -1218,8 +1217,7 @@ class RedirectHandler(RequestHandler):
             (r"/oldpath", web.RedirectHandler, {"url": "/newpath"}),
         ])
     """
-    def __init__(self, application, request, url, permanent=True):
-        RequestHandler.__init__(self, application, request)
+    def initialize(self, url, permanent=True):
         self._url = url
         self._permanent = permanent
 
@@ -1245,8 +1243,7 @@ class StaticFileHandler(RequestHandler):
     want browsers to cache a file indefinitely, send them to, e.g.,
     /static/images/myimage.png?v=xxx.
     """
-    def __init__(self, application, request, path, default_filename=None):
-        RequestHandler.__init__(self, application, request)
+    def initialize(self, path, default_filename=None):
         self.root = os.path.abspath(path) + os.path.sep
         self.default_filename = default_filename
 
@@ -1327,8 +1324,7 @@ class FallbackHandler(RequestHandler):
             (r".*", FallbackHandler, dict(fallback=wsgi_app),
         ])
     """
-    def __init__(self, app, request, fallback):
-        RequestHandler.__init__(self, app, request)
+    def initialize(self, fallback):
         self.fallback = fallback
 
     def prepare(self):