comparison dogdish/dispatcher.py @ 9:f517d80bafe0

more stubbing
author Jeff Hammel <jhammel@mozilla.com>
date Tue, 16 Oct 2012 16:49:29 -0700
parents ebb65758d725
children 5babc2ae6c27
comparison
equal deleted inserted replaced
8:ebb65758d725 9:f517d80bafe0
12 from webob import Response, exc 12 from webob import Response, exc
13 13
14 here = os.path.dirname(os.path.abspath(__file__)) 14 here = os.path.dirname(os.path.abspath(__file__))
15 15
16 class Handler(object): 16 class Handler(object):
17 """abstract handler object for a request"""
17 18
18 def __init__(self, request): 19 def __init__(self, request):
19 self.request = request 20 self.request = request
20 self.application_path = urlparse(request.application_url)[2] 21 self.application_path = urlparse(request.application_url)[2]
21 22
32 33
33 def redirect(self, location): 34 def redirect(self, location):
34 raise exc.HTTPSeeOther(location=location) 35 raise exc.HTTPSeeOther(location=location)
35 36
36 class Get(Handler): 37 class Get(Handler):
38 """handle GET requests"""
37 39
40 # template for response body
38 body = """<?xml version="1.0"?> 41 body = """<?xml version="1.0"?>
39 <updates> 42 <updates>
40 <update type="minor" appVersion="19.0a1" version="19.0a1" extensionVersion="19.0a1" buildID="20121010114416" licenseURL="http://www.mozilla.com/test/sample-eula.html" detailsURL="http://www.mozilla.com/test/sample-details.html"> 43 <update type="minor" appVersion="19.0a1" version="19.0a1" extensionVersion="19.0a1" buildID="20121010114416" licenseURL="http://www.mozilla.com/test/sample-eula.html" detailsURL="http://www.mozilla.com/test/sample-details.html">
41 <patch type="complete" URL="http://update.boot2gecko.org/nightly/b2g_update_2012-10-10_114416.mar%s" hashFunction="SHA512" hashValue="84edb1f53891cf983bc0f6066d31492f43e2d063aaceb05e1c51876f4fde81635afeb7ce3203dee6f65dd59be0cae5c73c49093b625c99acd4118000ad72dda8" size="42924805"/> 44 <patch type="complete" URL="http://update.boot2gecko.org/nightly/b2g_update_2012-10-10_114416.mar%(query)s" hashFunction="SHA512" hashValue="84edb1f53891cf983bc0f6066d31492f43e2d063aaceb05e1c51876f4fde81635afeb7ce3203dee6f65dd59be0cae5c73c49093b625c99acd4118000ad72dda8" size="42924805"/>
42 </update> 45 </update>
43 </updates>""" 46 </updates>"""
47
48 ### methods for request handler
44 49
45 @classmethod 50 @classmethod
46 def match(cls, request): 51 def match(cls, request):
47 return request.method == 'GET' 52 return request.method == 'GET'
48 53
61 66
62 return Response(content_type='text/xml', 67 return Response(content_type='text/xml',
63 body=body % query) 68 body=body % query)
64 69
65 class Dispatcher(object): 70 class Dispatcher(object):
71 """web application"""
72
66 73
67 ### class level variables 74 ### class level variables
68 defaults = {'directory': here} 75 defaults = {'directory': here}
69 76
70 def __init__(self, **kw): 77 def __init__(self, **kw):