comparison dogdish/dispatcher.py @ 1:2cb8b06d64df

minor fixes
author Jeff Hammel <jhammel@mozilla.com>
date Wed, 10 Oct 2012 16:23:02 -0700
parents b3fd8f98df32
children 4521527b93f6
comparison
equal deleted inserted replaced
0:b3fd8f98df32 1:2cb8b06d64df
1 #!/usr/bin/env python
2
1 """ 3 """
2 request dispatcher 4 dogdish
3 """ 5 """
4 6
5 from webob import Request, exc 7 from webob import Request, exc
6 8
7 from cgi import escape 9 from cgi import escape
8 from urlparse import urlparse 10 from urlparse import urlparse
9 from webob import Response, exc 11 from webob import Response, exc
10 12
11 class Handler(object): 13 class Handler(object):
14
12 def __init__(self, request): 15 def __init__(self, request):
13 self.request = request 16 self.request = request
14 self.application_path = urlparse(request.application_url)[2] 17 self.application_path = urlparse(request.application_url)[2]
15 18
16 def link(self, path=(), permanant=False): 19 def link(self, path=(), permanant=False):
39 @classmethod 42 @classmethod
40 def match(cls, request): 43 def match(cls, request):
41 return request.method == 'GET' 44 return request.method == 'GET'
42 45
43 def __call__(self): 46 def __call__(self):
44 name = self.request.GET.get('name', 'world') 47 return Response(content_type='text/xml',
45 retval = """<html><body><form method="post">Hello, 48 self.body)
46 <input type="text" name="name" value="%s"/></form></body></html>"""
47 return Response(content_type='text/html',
48 body=retval % name)
49 49
50 class Dispatcher(object): 50 class Dispatcher(object):
51 51
52 ### class level variables 52 ### class level variables
53 defaults = {} 53 defaults = {}