|
4781
|
1 #
|
|
|
2 # Example output when the web interface changes item 3 and the email
|
|
|
3 # (non pgp) interface changes item 4:
|
|
|
4 #
|
|
|
5 # tx_SourceCheckAudit(3) pre db.tx_Source: cgi
|
|
|
6 # tx_SourceCheckAudit(4) pre db.tx_Source: email
|
|
|
7 # tx_SourceCheckAudit(3) post db.tx_Source: cgi
|
|
|
8 # tx_SourceCheckAudit(4) post db.tx_Source: email
|
|
|
9 # tx_SourceCheckReact(4) pre db.tx_Source: email
|
|
|
10 # tx_SourceCheckReact(4) post db.tx_Source: email
|
|
|
11 # tx_SourceCheckReact(3) pre db.tx_Source: cgi
|
|
|
12 # tx_SourceCheckReact(3) post db.tx_Source: cgi
|
|
|
13 #
|
|
|
14 # Note that the calls are interleaved, but the proper
|
|
|
15 # tx_Source is associated with the same ticket.
|
|
|
16
|
|
|
17 import time as time
|
|
|
18
|
|
|
19 def tx_SourceCheckAudit(db, cl, nodeid, newvalues):
|
|
|
20 ''' An auditor to print the value of the source of the
|
|
|
21 transaction that trigger this change. The sleep call
|
|
|
22 is used to delay the transaction so that multiple changes will
|
|
|
23 overlap. The expected output from this detector are 2 lines
|
|
|
24 with the same value for tx_Source. Tx source is:
|
|
|
25 None - Reported when using a script or it is an error if
|
|
|
26 the change arrives by another method.
|
|
|
27 "cli" - reported when using roundup-admin
|
|
|
28 "web" - reported when using any web based technique
|
|
|
29 "email" - reported when using an unautheticated email based technique
|
|
|
30 "email-sig-openpgp" - reported when email with a valid pgp
|
|
|
31 signature is used
|
|
|
32 '''
|
|
|
33 if __debug__ and False:
|
|
|
34 print "\n tx_SourceCheckAudit(%s) db.tx_Source: %s"%(nodeid, db.tx_Source)
|
|
|
35
|
|
|
36 newvalues['tx_Source'] = db.tx_Source
|
|
|
37
|
|
|
38 # example use for real to prevent a change from happening if it's
|
|
|
39 # submited via email
|
|
|
40 #
|
|
|
41 # if db.tx_Source == "email":
|
|
|
42 # raise Reject, 'Change not allowed via email'
|
|
|
43
|
|
|
44 def tx_SourceCheckReact(db, cl, nodeid, oldvalues):
|
|
|
45 ''' An reactor to print the value of the source of the
|
|
|
46 transaction that trigger this change. The sleep call
|
|
|
47 is used to delay the transaction so that multiple changes will
|
|
|
48 overlap. The expected output from this detector are 2 lines
|
|
|
49 with the same value for tx_Source. Tx source is:
|
|
|
50 None - Reported when using a script or it is an error if
|
|
|
51 the change arrives by another method.
|
|
|
52 "cli" - reported when using roundup-admin
|
|
|
53 "web" - reported when using any web based technique
|
|
|
54 "email" - reported when using an unautheticated email based technique
|
|
|
55 "email-sig-openpgp" - reported when email with a valid pgp
|
|
|
56 signature is used
|
|
|
57 '''
|
|
|
58
|
|
|
59 if __debug__ and False:
|
|
|
60 print " tx_SourceCheckReact(%s) db.tx_Source: %s"%(nodeid, db.tx_Source)
|
|
|
61
|
|
|
62
|
|
|
63
|
|
|
64 def init(db):
|
|
|
65 db.issue.audit('create', tx_SourceCheckAudit)
|
|
|
66 db.issue.audit('set', tx_SourceCheckAudit)
|
|
|
67
|
|
|
68 db.issue.react('set', tx_SourceCheckReact)
|
|
|
69 db.issue.react('create', tx_SourceCheckReact)
|
|
|
70
|
|
|
71 db.msg.audit('create', tx_SourceCheckAudit)
|