changeset 5:f70d8f3aee51

allow app argument to allow use as middleware OOTB
author k0s <k0scist@gmail.com>
date Sun, 27 Dec 2009 16:38:50 -0500
parents ee9ed5875df0
children 9aa8f5721649
files setup.py webob_view/template/+package+/dispatcher.py
diffstat 2 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/setup.py	Mon Nov 02 17:50:39 2009 -0500
+++ b/setup.py	Sun Dec 27 16:38:50 2009 -0500
@@ -1,7 +1,7 @@
 from setuptools import setup, find_packages
 import sys, os
 
-version = '0.5'
+version = '0.6'
 
 setup(name='webob_view',
       version=version,
--- a/webob_view/template/+package+/dispatcher.py	Mon Nov 02 17:50:39 2009 -0500
+++ b/webob_view/template/+package+/dispatcher.py	Sun Dec 27 16:38:50 2009 -0500
@@ -8,12 +8,14 @@
 class Dispatcher(object):
 
     ### class level variables
-    defaults = {}
+    defaults = { 'app': None}
 
     def __init__(self, **kw):
         for key in self.defaults:
             setattr(self, key, kw.get(key, self.defaults[key]))
         self.handlers = [ Get, Post ]
+        if self.app:
+            assert hasattr(self.app, '__call__')
 
     ### methods dealing with HTTP
     def __call__(self, environ, start_response):
@@ -23,6 +25,8 @@
                 handler = h(request)
                 break
         else:
+            if self.app:
+                return self.app(environ, start_response)
             handler = exc.HTTPNotFound
         res = handler()
         return res(environ, start_response)