1 #!/usr/bin/python2.5 |
1 #!/usr/bin/python |
2 # Copyright 2009 Tero Marttila |
2 # Copyright 2009 Tero Marttila |
3 # |
3 # |
4 # This program is free software: you can redistribute it and/or modify |
4 # This program is free software: you can redistribute it and/or modify |
5 # it under the terms of the GNU General Public License as published by |
5 # it under the terms of the GNU General Public License as published by |
6 # the Free Software Foundation, either version 3 of the License, or |
6 # the Free Software Foundation, either version 3 of the License, or |
530 # parse options, force booleans if any form data was submitted, as checkboxes work that way |
530 # parse options, force booleans if any form data was submitted, as checkboxes work that way |
531 opts = options.parse(req.values, force_bool=bool(req.form)) |
531 opts = options.parse(req.values, force_bool=bool(req.form)) |
532 |
532 |
533 # build query string of req things |
533 # build query string of req things |
534 qargs = [ |
534 qargs = [ |
535 (opt.name, opt.build_list(val)) for opt, val in ( |
535 # XXX: eek, this is weird |
536 (options.options_by_name[opt_name], val) for opt_name, val in opts.iteritems() |
536 (opt.name, val) |
537 ) if val != opt.default |
537 for opt, vals in ( |
|
538 (options.options_by_name[opt_name], vals) for opt_name, vals in opts.iteritems() |
|
539 ) if vals != opt.default |
|
540 |
|
541 # unpack (a, [b, c]) -> (a, b), (a, c) |
|
542 for val in opt.build_list(vals) |
538 ] |
543 ] |
539 |
544 |
540 img_url = req.url_root + "logo" + ("?%s" % werkzeug.url_encode(qargs) if qargs else '') |
545 img_url = req.url_root + "logo" + ("?%s" % werkzeug.url_encode(qargs) if qargs else '') |
541 |
546 |
542 return werkzeug.Response("""\ |
547 return werkzeug.Response("""\ |
617 |
622 |
618 elif req.path == '/tile' : |
623 elif req.path == '/tile' : |
619 return handle_tile(req) |
624 return handle_tile(req) |
620 |
625 |
621 else : |
626 else : |
622 raise ValueError(req) |
627 raise ValueError(req.path) |
623 |
628 |
624 @werkzeug.Request.application |
629 @werkzeug.Request.application |
625 def wsgi_application (request) : |
630 def wsgi_application (request) : |
626 """ |
631 """ |
627 Our werkzeug WSGI handler |
632 Our werkzeug WSGI handler |