Mercurial > p > roundup > code
annotate roundup/cgi/exceptions.py @ 2133:f01befe8a7fe
*** empty log message ***
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Fri, 26 Mar 2004 01:19:25 +0000 |
| parents | 3fd672293712 |
| children | 93bd8c4d43ef |
| rev | line source |
|---|---|
|
2129
3fd672293712
add and use Reject exception [SF#700265]
Richard Jones <richard@users.sourceforge.net>
parents:
2062
diff
changeset
|
1 #$Id: exceptions.py,v 1.4 2004-03-26 00:44:11 richard Exp $ |
|
3fd672293712
add and use Reject exception [SF#700265]
Richard Jones <richard@users.sourceforge.net>
parents:
2062
diff
changeset
|
2 '''Exceptions for use in Roundup's web interface. |
|
3fd672293712
add and use Reject exception [SF#700265]
Richard Jones <richard@users.sourceforge.net>
parents:
2062
diff
changeset
|
3 ''' |
|
3fd672293712
add and use Reject exception [SF#700265]
Richard Jones <richard@users.sourceforge.net>
parents:
2062
diff
changeset
|
4 |
|
3fd672293712
add and use Reject exception [SF#700265]
Richard Jones <richard@users.sourceforge.net>
parents:
2062
diff
changeset
|
5 __docformat__ = 'restructuredtext' |
|
3fd672293712
add and use Reject exception [SF#700265]
Richard Jones <richard@users.sourceforge.net>
parents:
2062
diff
changeset
|
6 |
|
2062
f6d7ccce8d96
cgi exceptions fix
Richard Jones <richard@users.sourceforge.net>
parents:
2052
diff
changeset
|
7 import cgi |
|
f6d7ccce8d96
cgi exceptions fix
Richard Jones <richard@users.sourceforge.net>
parents:
2052
diff
changeset
|
8 |
|
2004
1782fe36e7b8
Move out parts of client.py to new modules:
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents:
diff
changeset
|
9 class HTTPException(Exception): |
|
1782fe36e7b8
Move out parts of client.py to new modules:
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents:
diff
changeset
|
10 pass |
|
1782fe36e7b8
Move out parts of client.py to new modules:
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents:
diff
changeset
|
11 |
|
1782fe36e7b8
Move out parts of client.py to new modules:
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents:
diff
changeset
|
12 class Unauthorised(HTTPException): |
|
1782fe36e7b8
Move out parts of client.py to new modules:
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents:
diff
changeset
|
13 pass |
|
1782fe36e7b8
Move out parts of client.py to new modules:
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents:
diff
changeset
|
14 |
|
1782fe36e7b8
Move out parts of client.py to new modules:
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents:
diff
changeset
|
15 class Redirect(HTTPException): |
|
1782fe36e7b8
Move out parts of client.py to new modules:
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents:
diff
changeset
|
16 pass |
|
1782fe36e7b8
Move out parts of client.py to new modules:
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents:
diff
changeset
|
17 |
|
1782fe36e7b8
Move out parts of client.py to new modules:
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents:
diff
changeset
|
18 class NotFound(HTTPException): |
|
1782fe36e7b8
Move out parts of client.py to new modules:
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents:
diff
changeset
|
19 pass |
|
1782fe36e7b8
Move out parts of client.py to new modules:
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents:
diff
changeset
|
20 |
|
1782fe36e7b8
Move out parts of client.py to new modules:
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents:
diff
changeset
|
21 class NotModified(HTTPException): |
|
1782fe36e7b8
Move out parts of client.py to new modules:
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents:
diff
changeset
|
22 pass |
|
1782fe36e7b8
Move out parts of client.py to new modules:
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents:
diff
changeset
|
23 |
|
1782fe36e7b8
Move out parts of client.py to new modules:
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents:
diff
changeset
|
24 class FormError(ValueError): |
|
1782fe36e7b8
Move out parts of client.py to new modules:
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents:
diff
changeset
|
25 """An 'expected' exception occurred during form parsing. |
|
1782fe36e7b8
Move out parts of client.py to new modules:
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents:
diff
changeset
|
26 |
|
1782fe36e7b8
Move out parts of client.py to new modules:
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents:
diff
changeset
|
27 That is, something we know can go wrong, and don't want to alarm the user |
|
1782fe36e7b8
Move out parts of client.py to new modules:
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents:
diff
changeset
|
28 with. |
|
1782fe36e7b8
Move out parts of client.py to new modules:
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents:
diff
changeset
|
29 |
|
1782fe36e7b8
Move out parts of client.py to new modules:
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents:
diff
changeset
|
30 We trap this at the user interface level and feed back a nice error to the |
|
1782fe36e7b8
Move out parts of client.py to new modules:
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents:
diff
changeset
|
31 user. |
|
1782fe36e7b8
Move out parts of client.py to new modules:
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents:
diff
changeset
|
32 |
|
1782fe36e7b8
Move out parts of client.py to new modules:
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents:
diff
changeset
|
33 """ |
|
1782fe36e7b8
Move out parts of client.py to new modules:
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents:
diff
changeset
|
34 pass |
|
1782fe36e7b8
Move out parts of client.py to new modules:
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents:
diff
changeset
|
35 |
|
1782fe36e7b8
Move out parts of client.py to new modules:
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents:
diff
changeset
|
36 class SendFile(Exception): |
|
1782fe36e7b8
Move out parts of client.py to new modules:
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents:
diff
changeset
|
37 """Send a file from the database.""" |
|
1782fe36e7b8
Move out parts of client.py to new modules:
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents:
diff
changeset
|
38 |
|
1782fe36e7b8
Move out parts of client.py to new modules:
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents:
diff
changeset
|
39 class SendStaticFile(Exception): |
|
1782fe36e7b8
Move out parts of client.py to new modules:
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents:
diff
changeset
|
40 """Send a static file from the instance html directory.""" |
|
2052
78e6a1e4984e
forward-port from maint branch
Richard Jones <richard@users.sourceforge.net>
parents:
2004
diff
changeset
|
41 |
|
78e6a1e4984e
forward-port from maint branch
Richard Jones <richard@users.sourceforge.net>
parents:
2004
diff
changeset
|
42 class SeriousError(Exception): |
|
78e6a1e4984e
forward-port from maint branch
Richard Jones <richard@users.sourceforge.net>
parents:
2004
diff
changeset
|
43 """Raised when we can't reasonably display an error message on a |
|
78e6a1e4984e
forward-port from maint branch
Richard Jones <richard@users.sourceforge.net>
parents:
2004
diff
changeset
|
44 templated page. |
|
78e6a1e4984e
forward-port from maint branch
Richard Jones <richard@users.sourceforge.net>
parents:
2004
diff
changeset
|
45 |
|
78e6a1e4984e
forward-port from maint branch
Richard Jones <richard@users.sourceforge.net>
parents:
2004
diff
changeset
|
46 The exception value will be displayed in the error page, HTML |
|
78e6a1e4984e
forward-port from maint branch
Richard Jones <richard@users.sourceforge.net>
parents:
2004
diff
changeset
|
47 escaped. |
|
78e6a1e4984e
forward-port from maint branch
Richard Jones <richard@users.sourceforge.net>
parents:
2004
diff
changeset
|
48 """ |
|
78e6a1e4984e
forward-port from maint branch
Richard Jones <richard@users.sourceforge.net>
parents:
2004
diff
changeset
|
49 def __str__(self): |
|
78e6a1e4984e
forward-port from maint branch
Richard Jones <richard@users.sourceforge.net>
parents:
2004
diff
changeset
|
50 return ''' |
|
78e6a1e4984e
forward-port from maint branch
Richard Jones <richard@users.sourceforge.net>
parents:
2004
diff
changeset
|
51 <html><head><title>Roundup issue tracker: An error has occurred</title> |
|
78e6a1e4984e
forward-port from maint branch
Richard Jones <richard@users.sourceforge.net>
parents:
2004
diff
changeset
|
52 <meta http-equiv="Content-Type" content="text/html; charset=utf-8;"> |
|
78e6a1e4984e
forward-port from maint branch
Richard Jones <richard@users.sourceforge.net>
parents:
2004
diff
changeset
|
53 <link rel="stylesheet" type="text/css" href="_file/style.css"> |
|
78e6a1e4984e
forward-port from maint branch
Richard Jones <richard@users.sourceforge.net>
parents:
2004
diff
changeset
|
54 </head> |
|
78e6a1e4984e
forward-port from maint branch
Richard Jones <richard@users.sourceforge.net>
parents:
2004
diff
changeset
|
55 <body class="body" marginwidth="0" marginheight="0"> |
|
78e6a1e4984e
forward-port from maint branch
Richard Jones <richard@users.sourceforge.net>
parents:
2004
diff
changeset
|
56 <p class="error-message">%s</p> |
|
78e6a1e4984e
forward-port from maint branch
Richard Jones <richard@users.sourceforge.net>
parents:
2004
diff
changeset
|
57 </body></html> |
|
78e6a1e4984e
forward-port from maint branch
Richard Jones <richard@users.sourceforge.net>
parents:
2004
diff
changeset
|
58 '''%cgi.escape(self.args[0]) |
|
78e6a1e4984e
forward-port from maint branch
Richard Jones <richard@users.sourceforge.net>
parents:
2004
diff
changeset
|
59 |
|
2129
3fd672293712
add and use Reject exception [SF#700265]
Richard Jones <richard@users.sourceforge.net>
parents:
2062
diff
changeset
|
60 # vim: set filetype=python ts=4 sw=4 et si |
