Mercurial > p > roundup > code
annotate detectors/creator_resolution.py @ 3896:fca0365521fc
ignore client shutdown exceptions when sending responses
patch from Ulrik Miaelsson
If the user clicks the stop button, or click another link before
the previous has finished loading, or something similar an IOError
exception will be raised which results in the admin being sent an
email.
This can understandably be pretty annoying if your users are
doing that on a regular basis. So we'll trap that exception
and ignore it.
| author | Justus Pendleton <jpend@users.sourceforge.net> |
|---|---|
| date | Tue, 11 Sep 2007 21:30:14 +0000 |
| parents | 43151ac10819 |
| children |
| rev | line source |
|---|---|
|
2194
43151ac10819
*** empty log message ***
Richard Jones <richard@users.sourceforge.net>
parents:
2193
diff
changeset
|
1 # This detector was written by richard@mechanicalcat.net and it's been |
|
43151ac10819
*** empty log message ***
Richard Jones <richard@users.sourceforge.net>
parents:
2193
diff
changeset
|
2 # placed in the Public Domain. Copy and modify to your heart's content. |
|
43151ac10819
*** empty log message ***
Richard Jones <richard@users.sourceforge.net>
parents:
2193
diff
changeset
|
3 |
|
43151ac10819
*** empty log message ***
Richard Jones <richard@users.sourceforge.net>
parents:
2193
diff
changeset
|
4 #$Id: creator_resolution.py,v 1.2 2004-04-07 06:32:54 richard Exp $ |
|
2193
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
5 |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
6 from roundup.exceptions import Reject |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
7 |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
8 def creator_resolution(db, cl, nodeid, newvalues): |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
9 '''Catch attempts to set the status to "resolved" - if the assignedto |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
10 user isn't the creator, then set the status to "in-progress" (try |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
11 "confirm-done" first though, but "classic" Roundup doesn't have that |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
12 status) |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
13 ''' |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
14 if not newvalues.has_key('status'): |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
15 return |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
16 |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
17 # get the resolved state ID |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
18 resolved_id = db.status.lookup('resolved') |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
19 |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
20 if newvalues['status'] != resolved_id: |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
21 return |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
22 |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
23 # check the assignedto |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
24 assignedto = newvalues.get('assignedto', cl.get(nodeid, 'assignedto')) |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
25 creator = cl.get(nodeid, 'creator') |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
26 if assignedto == creator: |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
27 if db.getuid() != creator: |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
28 name = db.user.get(creator, 'username') |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
29 raise Reject, 'Only the creator (%s) may close this issue'%name |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
30 return |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
31 |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
32 # set the assignedto and status |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
33 newvalues['assignedto'] = creator |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
34 try: |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
35 status = db.status.lookup('confirm-done') |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
36 except KeyError: |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
37 status = db.status.lookup('in-progress') |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
38 newvalues['status'] = status |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
39 |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
40 def init(db): |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
41 db.issue.audit('set', creator_resolution) |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
42 |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
43 # vim: set filetype=python ts=4 sw=4 et si |
