Mercurial > p > roundup > code
annotate roundup/test/tx_Source_detector.py @ 6739:00fe67eb8a91
Update locations templates and locale files are stored
Installing on a new ubuntu 22.04 venv at /tmp/roundup, I found the
locale and template files installed under
/tmp/roundup2/lib/python3.10/site-packages/usr/local/share which was
unexpected.
/tmp/roundup2/lib/python3.10/site-packages/tmp/roundup2/share would be
expected. Why sys.prefix (/tmp/roundup2) was not being used but
sys.base_prefix (/usr) and 'local' were added in I have no idea.
In any case, updated admin and i18n code to find the files in this
location.
Suggested building a venv for installation with commands in
installation.txt. Removed search for templates top level
directory. Was used for the old location of the tracker templates
pre-2009 when they were moved under share/roundup/templates.
left print statemts for debugging directory search in admin templates.
They are disabled by a variable set to False. At some point will add
pragma's to admin to set debugging and other options see issue
2551103.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Tue, 28 Jun 2022 23:16:47 -0400 |
| parents | 58817c3bf471 |
| children | 137aabd876ad |
| rev | line source |
|---|---|
| 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 | |
|
5376
64b05e24dbd8
Python 3 preparation: convert print to a function.
Joseph Myers <jsm@polyomino.org.uk>
parents:
4781
diff
changeset
|
17 from __future__ import print_function |
| 4781 | 18 import time as time |
| 19 | |
| 20 def tx_SourceCheckAudit(db, cl, nodeid, newvalues): | |
| 21 ''' An auditor to print the value of the source of the | |
| 22 transaction that trigger this change. The sleep call | |
| 23 is used to delay the transaction so that multiple changes will | |
| 24 overlap. The expected output from this detector are 2 lines | |
| 25 with the same value for tx_Source. Tx source is: | |
| 26 None - Reported when using a script or it is an error if | |
| 27 the change arrives by another method. | |
| 28 "cli" - reported when using roundup-admin | |
|
5881
9938c40e03bc
Add "rest" and "xmlrpc" values for database tx_Source property
John Rouillard <rouilj@ieee.org>
parents:
5376
diff
changeset
|
29 "web" - reported when using html based web pages |
|
9938c40e03bc
Add "rest" and "xmlrpc" values for database tx_Source property
John Rouillard <rouilj@ieee.org>
parents:
5376
diff
changeset
|
30 "rest" - reported when using the /rest web API |
|
9938c40e03bc
Add "rest" and "xmlrpc" values for database tx_Source property
John Rouillard <rouilj@ieee.org>
parents:
5376
diff
changeset
|
31 "xmlrpc" - reported when using the /xmlrpc web API |
| 4781 | 32 "email" - reported when using an unautheticated email based technique |
| 33 "email-sig-openpgp" - reported when email with a valid pgp | |
| 34 signature is used | |
| 35 ''' | |
| 36 if __debug__ and False: | |
|
5376
64b05e24dbd8
Python 3 preparation: convert print to a function.
Joseph Myers <jsm@polyomino.org.uk>
parents:
4781
diff
changeset
|
37 print("\n tx_SourceCheckAudit(%s) db.tx_Source: %s"%(nodeid, db.tx_Source)) |
| 4781 | 38 |
| 39 newvalues['tx_Source'] = db.tx_Source | |
| 40 | |
| 41 # example use for real to prevent a change from happening if it's | |
| 42 # submited via email | |
| 43 # | |
| 44 # if db.tx_Source == "email": | |
| 45 # raise Reject, 'Change not allowed via email' | |
| 46 | |
| 47 def tx_SourceCheckReact(db, cl, nodeid, oldvalues): | |
| 48 ''' An reactor to print the value of the source of the | |
| 49 transaction that trigger this change. The sleep call | |
| 50 is used to delay the transaction so that multiple changes will | |
| 51 overlap. The expected output from this detector are 2 lines | |
| 52 with the same value for tx_Source. Tx source is: | |
| 53 None - Reported when using a script or it is an error if | |
| 54 the change arrives by another method. | |
| 55 "cli" - reported when using roundup-admin | |
|
5881
9938c40e03bc
Add "rest" and "xmlrpc" values for database tx_Source property
John Rouillard <rouilj@ieee.org>
parents:
5376
diff
changeset
|
56 "web" - reported when using html based web pages |
|
9938c40e03bc
Add "rest" and "xmlrpc" values for database tx_Source property
John Rouillard <rouilj@ieee.org>
parents:
5376
diff
changeset
|
57 "rest" - reported when using the /rest web API |
|
9938c40e03bc
Add "rest" and "xmlrpc" values for database tx_Source property
John Rouillard <rouilj@ieee.org>
parents:
5376
diff
changeset
|
58 "xmlrpc" - reported when using the /xmlrpc web API |
| 4781 | 59 "email" - reported when using an unautheticated email based technique |
| 60 "email-sig-openpgp" - reported when email with a valid pgp | |
| 61 signature is used | |
| 62 ''' | |
| 63 | |
| 64 if __debug__ and False: | |
|
5376
64b05e24dbd8
Python 3 preparation: convert print to a function.
Joseph Myers <jsm@polyomino.org.uk>
parents:
4781
diff
changeset
|
65 print(" tx_SourceCheckReact(%s) db.tx_Source: %s"%(nodeid, db.tx_Source)) |
| 4781 | 66 |
| 67 | |
| 68 | |
| 69 def init(db): | |
| 70 db.issue.audit('create', tx_SourceCheckAudit) | |
| 71 db.issue.audit('set', tx_SourceCheckAudit) | |
| 72 | |
| 73 db.issue.react('set', tx_SourceCheckReact) | |
| 74 db.issue.react('create', tx_SourceCheckReact) | |
| 75 | |
| 76 db.msg.audit('create', tx_SourceCheckAudit) |
