Mercurial > hg > TagInTheMiddle
diff 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 |
line wrap: on
line diff
--- a/taginthemiddle/handlers.py Tue May 04 18:46:05 2010 -0700 +++ b/taginthemiddle/handlers.py Tue May 04 19:15:21 2010 -0700 @@ -70,16 +70,51 @@ methods = set(['GET']) @classmethod - def match( + def match(cls, app, request): + + # check the method + if request.method not in cls.methods: + return None + + # check the path + if request.path_info.endswith('/%s' % app.tags_url): + try: + return cls(app, request) + except HandlerMatchException: + return None + class ViewTags(GenshiHandler): # TODO: RSS template = 'tags.html' methods = set(['GET']) + def __init__(self, app, request): + GenshiHandler.__init__(self, app, request) + path = request.path_info.split('/') + try: + index = path.find(app.tags_url) + except ValueError: + raise HandlerMatchException + self.tags = path[index+1:] + if not self.tags: + raise HandlerMatchException + + @classmethod def match(cls, app, request): - pass - + # check the method + if request.method not in cls.methods: + return None + + try: + return cls(app, request) + except HandlerMatchException: + return None + + def Get(self): + if self.request.GET.get('format') == 'rss': + pass # TODO + return GenshiHandler.Get(self) class PostTags(Handler): methods = set(['POST'])