Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(156)

Side by Side Diff: third_party/twisted_8_1/twisted/web/error.py

Issue 12261012: Remove third_party/twisted_8_1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1
2 # Copyright (c) 2001-2004 Twisted Matrix Laboratories.
3 # See LICENSE for details.
4
5
6 """I am the Twisted.Web error resources and exceptions."""
7
8 #t.w imports
9 import resource
10
11 from twisted.web import http
12
13 class Error(Exception):
14 def __init__(self, code, message = None, response = None):
15 message = message or http.responses.get(code)
16 Exception.__init__(self, code, message, response)
17 self.status = code
18 self.response = response
19
20 def __str__(self):
21 return '%s %s' % (self[0], self[1])
22
23 class PageRedirect(Error):
24 """A request that resulted in a http redirect """
25 def __init__(self, code, message = None, response = None, location = None):
26 message = message or ("%s to %s" % (http.responses.get(code), location))
27 Error.__init__(self, code, message, response)
28 self.location = location
29
30 class ErrorPage(resource.Resource):
31 def __init__(self, status, brief, detail):
32 resource.Resource.__init__(self)
33 self.code = status
34 self.brief = brief
35 self.detail = detail
36
37 def render(self, request):
38 request.setResponseCode(self.code)
39 request.setHeader("content-type", "text/html")
40 return ("""<html>
41 <head><title>%s - %s</title></head>
42 <body><h1>%s</h1>
43 <p>%s</p>
44 </body></html>\n\n""" %
45 (self.code, self.brief, self.brief, self.detail))
46
47 def getChild(self, chnam, request):
48 return self
49
50
51 class NoResource(ErrorPage):
52 def __init__(self, message="Sorry. No luck finding that resource."):
53 ErrorPage.__init__(self, http.NOT_FOUND,
54 "No Such Resource",
55 message)
56
57 class ForbiddenResource(ErrorPage):
58 def __init__(self, message="Sorry, resource is forbidden."):
59 ErrorPage.__init__(self, http.FORBIDDEN,
60 "Forbidden Resource",
61 message)
OLDNEW
« no previous file with comments | « third_party/twisted_8_1/twisted/web/domhelpers.py ('k') | third_party/twisted_8_1/twisted/web/google.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698