diff options
author | Jon Bergli Heier <snakebite@jvnv.net> | 2010-01-27 23:25:32 +0100 |
---|---|---|
committer | Jon Bergli Heier <snakebite@jvnv.net> | 2010-01-27 23:25:32 +0100 |
commit | 990a5db0a543c4d69a58ee8a0046adee1c9efbc5 (patch) | |
tree | 1c25f60254a80b76da87eaf46e787b43ed19b89f | |
parent | bc9a28327b5bf22d0cc218a4e852b128fd940a2b (diff) |
Replace manual messages with self.message.
Fixed calling start_response in self.message.
-rw-r--r-- | pastepy.py | 8 |
1 files changed, 3 insertions, 5 deletions
@@ -23,7 +23,7 @@ class Paste(object): self.formatter = HtmlFormatter(linenos = 'table', lineanchors = 'line', anchorlinenos = True) def message(self, msg, title = 'Message'): - start_response('200 OK', [('Content-Type', 'text/html')]) + self.start_response('200 OK', [('Content-Type', 'text/html')]) return [str(templates.message(searchList = { 'title': '%s – %s' % (settings.pastebin_name, title), 'header': title, @@ -39,8 +39,7 @@ class Paste(object): elif mp['type'].value == 'Paste': return self.add_paste(mp) else: - self.start_response('400 Bad Request', [('Content-Type', 'text/plain')]) - return ['Invalid type "%s".' % mp['type'].value] + return self.message('Invalid type "%s".' % mp['type'].value, 'Error') self.start_response('200 OK', [('Content-Type', 'text/html')]) return [str(templates.paste(searchList = { 'title': settings.pastebin_name, @@ -170,8 +169,7 @@ class Paste(object): self.path = path return getattr(self, module)() else: - start_response('404 Not Found', [('Content-Type', 'text/html'), ('Location', '/')]) - return ['<a href="/">/</a>'] + return self.message('Invalid module requested.', 'Error') if __name__ == '__main__': from wsgiref.simple_server import make_server |