4 __author__ = "Oleg Broytman <phd@phdru.name>"
5 __copyright__ = "Copyright (C) 2014 PhiloSoft Design"
6 __license__ = "GNU GPL"
9 from ply.lex import LexError
11 from html.response import redirect, response
12 from parser.parser import parser
14 form = cgi.FieldStorage()
15 if not form.has_key('q'):
16 status = "400 Bad request"
18 body = "Required parameter is missing!"
23 tree = parser.parse(q)
27 status = "400 Bad request"
29 body = "Bad query syntax!"
30 elif tree[0] == 'NAME': # Single tag - just do redirect
32 assert isinstance(tag, str)
33 from tags import tag_exists
35 redirect("/Russian/blog/tags/%s.html" % tag, status="301 Moved")
37 status = "404 Tag not found"
39 body = "Tag does not exist!"
41 response(title, body, status)