From 990a5db0a543c4d69a58ee8a0046adee1c9efbc5 Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Wed, 27 Jan 2010 23:25:32 +0100 Subject: Replace manual messages with self.message. Fixed calling start_response in self.message. --- pastepy.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pastepy.py b/pastepy.py index 6485c24..cc5514d 100644 --- a/pastepy.py +++ b/pastepy.py @@ -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 ['/'] + return self.message('Invalid module requested.', 'Error') if __name__ == '__main__': from wsgiref.simple_server import make_server -- cgit v1.2.3