comparison taginthemiddle/handlers.py @ 2:1182315b18ac

add rudimentary code for handlers
author Jeff Hammel <jhammel@mozilla.com>
date Tue, 04 May 2010 19:15:21 -0700
parents 1c5cbbde4299
children fc55d95be553
comparison
equal deleted inserted replaced
1:837cfc05d4d9 2:1182315b18ac
68 class TagCloud(GenshiHandler): 68 class TagCloud(GenshiHandler):
69 template = 'cloud.html' 69 template = 'cloud.html'
70 methods = set(['GET']) 70 methods = set(['GET'])
71 71
72 @classmethod 72 @classmethod
73 def match( 73 def match(cls, app, request):
74
75 # check the method
76 if request.method not in cls.methods:
77 return None
78
79 # check the path
80 if request.path_info.endswith('/%s' % app.tags_url):
81 try:
82 return cls(app, request)
83 except HandlerMatchException:
84 return None
85
74 86
75 class ViewTags(GenshiHandler): 87 class ViewTags(GenshiHandler):
76 # TODO: RSS 88 # TODO: RSS
77 template = 'tags.html' 89 template = 'tags.html'
78 methods = set(['GET']) 90 methods = set(['GET'])
79 91
92 def __init__(self, app, request):
93 GenshiHandler.__init__(self, app, request)
94 path = request.path_info.split('/')
95 try:
96 index = path.find(app.tags_url)
97 except ValueError:
98 raise HandlerMatchException
99 self.tags = path[index+1:]
100 if not self.tags:
101 raise HandlerMatchException
102
103 @classmethod
80 def match(cls, app, request): 104 def match(cls, app, request):
81 pass 105 # check the method
82 106 if request.method not in cls.methods:
107 return None
108
109 try:
110 return cls(app, request)
111 except HandlerMatchException:
112 return None
113
114 def Get(self):
115 if self.request.GET.get('format') == 'rss':
116 pass # TODO
117 return GenshiHandler.Get(self)
83 118
84 class PostTags(Handler): 119 class PostTags(Handler):
85 methods = set(['POST']) 120 methods = set(['POST'])
86 121
87 @classmethod 122 @classmethod