Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Have a look at these fixes #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 10 additions & 23 deletions webapp2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,27 +143,8 @@ def __init__(self, request=None, response=None):
self.request = request
self.response = response
self.app = request.app
self.dispatch()

def initialize(self, request, response):
"""Initializes this request handler with the given WSGI application,
Request and Response.

.. warning::
This is deprecated. It is here for compatibility with webapp only.
Use __init__() instead.

:param request:
A :class:`Request` instance.
:param response:
A :class:`Response` instance.
"""
from warnings import warn
warn(DeprecationWarning('RequestHandler.initialize() is deprecated. '
'Use __init__() instead.'))
self.request = request
self.response = response
self.app = WSGIApplication.active_instance
if hasattr(self, 'initialize') and callable(self.initialize):
self.initialize(request, response)

def dispatch(self):
"""Dispatches the request.
Expand Down Expand Up @@ -770,8 +751,14 @@ def dispatch(self, request, response):
except Exception, e:
handler.handle_exception(e, request.app.debug)
else:
# A function or webapp2.RequestHandler: just call it.
handler_spec(request, response)
if issubclass(handler_spec, RequestHandler):
# Initialize the Handler object (so that derived Handler classes work properly)
handler = handler_spec(request, response)
# then call it
handler.dispatch()
else:
# A function just call it.
handler_spec(request, response)

def set_builder(self, func):
"""Sets a the function called for building URLs.
Expand Down