[tipfy] push by rodrigo.moraes - AbstractRequestHandler interface checking is no longer needed. on 2011-03-20 20:58 GMT

0 views
Skip to first unread message

ti...@googlecode.com

unread,
Mar 20, 2011, 4:59:08 PM3/20/11
to tipfy-...@googlegroups.com
Revision: a9d3d27660fb
Author: Rodrigo Moraes <rodrigo...@gmail.com>
Date: Sun Mar 20 13:58:27 2011
Log: AbstractRequestHandler interface checking is no longer needed.
http://code.google.com/p/tipfy/source/detail?r=a9d3d27660fb

Modified:
/tipfy/app.py
/tipfy/routing.py

=======================================
--- /tipfy/app.py Sun Mar 20 06:06:06 2011
+++ /tipfy/app.py Sun Mar 20 13:58:27 2011
@@ -61,23 +61,25 @@
SERVER_SOFTWARE.startswith('Google App Engine')))


-class AbstractRequestHandler(object):
- """RequestHandler interface."""
-
- def __init__(self, app, request):
- raise NotImplementedError()
-
- def __call__(self):
- raise NotImplementedError()
-
-
-class BaseRequestHandler(AbstractRequestHandler):
+class BaseRequestHandler(object):
"""Base class to handle requests. This is the central piece for an
application and provides access to the current WSGI app and request.
Additionally it provides lazy access to auth, i18n and session stores,
and several utilities to handle a request.
- """
-
+
+ Although it is convenient to extend this class
(or :class:`RequestHandler`)
+ and some extended functionality like sessions is implemented on top of
it,
+ the only required interface by the WSGI app is the following:
+
+ class RequestHandler(object):
+ def __init__(self, app, request):
+ pass
+
+ def __call__(self):
+ return Response()
+
+ A Tipfy-compatible handler can be implemented using only these two
methods.
+ """
def __init__(self, app, request):
"""Initializes the handler.

@@ -96,11 +98,6 @@
must return a :attr:`response_class` object. If :attr:`middleware`
are
defined, use their hooks to process the request or handle
exceptions.

- :param _method:
- The method to be dispatched, normally the request method in
- lower case, e.g., 'get', 'post', 'head' or 'put'.
- :param kwargs:
- Keyword arguments from the matched :class:`Rule`.
:returns:
A :attr:`response_class` instance.
"""
=======================================
--- /tipfy/routing.py Sun Mar 20 06:06:06 2011
+++ /tipfy/routing.py Sun Mar 20 13:58:27 2011
@@ -86,8 +86,6 @@
:returns:
A :class:`tipfy.Response` instance.
"""
- from tipfy.app import AbstractRequestHandler
-
rule, rule_args = self.match(request)
handler = rule.handler
if isinstance(handler, basestring):

Reply all
Reply to author
Forward
0 new messages