# # Example output when the web interface changes item 3 and the email # (non pgp) interface changes item 4: # # txSourceCheckAudit(3) pre db.txSource: cgi # txSourceCheckAudit(4) pre db.txSource: email # txSourceCheckAudit(3) post db.txSource: cgi # txSourceCheckAudit(4) post db.txSource: email # txSourceCheckReact(4) pre db.txSource: email # txSourceCheckReact(4) post db.txSource: email # txSourceCheckReact(3) pre db.txSource: cgi # txSourceCheckReact(3) post db.txSource: cgi # # Note that the calls are interleaved, but the proper # txSource is associated with the same ticket. import time as time def txSourceCheckAudit(db, cl, nodeid, newvalues): ''' An auditor to print the value of the source of the transaction that trigger this change. The sleep call is used to delay the transaction so that multiple changes will overlap. The expected output from this detector are 2 lines with the same value for txSource. Tx source is: unset - reported when using a script/roundup-admin cgi - reported when using any web based technique email - reported when using any email based technique email/pgp - reported when email based technique uses pgp signed emails ''' print "txSourceCheckAudit(%s) pre db.txSource: %s"%(nodeid, db.txSource) time.sleep(10) print "txSourceCheckAudit(%s) post db.txSource: %s"%(nodeid, db.txSource) # example use for real to prevent a change from happening if it's # submited via email # # if db.txSource == "email": # raise Reject, 'Change not allowed via email' def txSourceCheckReact(db, cl, nodeid, oldvalues): ''' An reactor to print the value of the source of the transaction that trigger this change. The sleep call is used to delay the transaction so that multiple changes will overlap. The expected output from this detector are 2 lines with the same value for txSource. Tx source is: unset - reported when using a script/roundup-admin cgi - reported when using any web based technique email - reported when using any email based technique email/pgp - reported when email based technique uses pgp signed emails ''' print "txSourceCheckReact(%s) pre db.txSource: %s"%(nodeid, db.txSource) time.sleep(10) print "txSourceCheckReact(%s) post db.txSource: %s"%(nodeid, db.txSource) def init(db): db.issue.audit('set', txSourceCheckAudit) db.issue.audit('create', txSourceCheckAudit) db.issue.react('set', txSourceCheckReact) db.issue.react('create', txSourceCheckReact)