annotate roundup/exceptions.py @ 6814:3f60a71b0812

Summary: Support selecion session/otk data store. Add redis as data store. Allow admin to select the backend data store. Compatibility matrix: main\/ session>| anydbm | sqlite | redis | mysql | postgresql | anydbm | D | | X | | | sqlite | X | D | X | | | mysql | | | | D | | postgresql | | | | | D | --------------------------------------------------------------+ D - default if unconfigured, X - compatible choice DETAILS roundup/configuration.py: add config.ini section sessiondb with settings: backend and redis_url. CHANGES.txt, doc/admin_guide.txt, doc/installation.txt, doc/upgrading.txt: doc on config of session db and redis. Plus some other fixes: admin - clarified why we do not drop __words and __testids table in native-fts conversion. TYpo fix. upgrading - doc how you can keep using anydbm for session data with sqlite. Fix dupe sentence in an upgrading config.ini section. roundup/backends/back_anydbm.py, roundup/backends/back_sqlite.py: code to support redis, redis/anydbm backends respectively. roundup/backends/sessions_redis.py new storage backend for redis. roundup/rest.py, roundup/cgi/actions.py, roundup/cgi/templating.py redis uses a different way of calculating lifetime/timestamp. Since expiration of an item occurred if its timestamp was more than 1 week old, code would calculate: now - 1 week + lifetime. But this results in faster expiration in redis if used for lifetime/timestamp. Convert code to use the lifetime() method in BasicDatabase that generates the right timestamp for each backend. test/session_common.py: added tests for more cases, get without default, getall non-existing key etc. timestamp test changed to use new self.get_ts which is overridden in other tests. Test that datatypes survive storage. test/test_redis_session.py: test redis session store with sqlite and anydbm primary databases test/test_anydbm.py, test/test_sqlite.py add test to make sure the databases are properly set up sqlite - add test cases where anydbm is used as datastore anydbm - remove updateTimestamp override add get_ts(). test/test_config.py tests on redis_url and compatibility on choice of sessiondb backend .travis.yml: add redis db and redis-py
author John Rouillard <rouilj@ieee.org>
date Thu, 04 Aug 2022 14:41:58 -0400
parents c177e7128dc9
children e16b7d47fdb2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4083
bbab97f8ffb2 XMLRPC improvements:
Stefan Seefeld <stefan@seefeld.name>
parents: 4066
diff changeset
1 """Exceptions for use across all Roundup components.
bbab97f8ffb2 XMLRPC improvements:
Stefan Seefeld <stefan@seefeld.name>
parents: 4066
diff changeset
2 """
2129
3fd672293712 add and use Reject exception [SF#700265]
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
3
3fd672293712 add and use Reject exception [SF#700265]
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
4 __docformat__ = 'restructuredtext'
3fd672293712 add and use Reject exception [SF#700265]
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
5
6005
292c9dfd06bd flake8 formatting fixes.
John Rouillard <rouilj@ieee.org>
parents: 5264
diff changeset
6
6123
c177e7128dc9 issue2551083 Replace BaseException and Exception with RoundupException
John Rouillard <rouilj@ieee.org>
parents: 6005
diff changeset
7 class RoundupException(Exception):
c177e7128dc9 issue2551083 Replace BaseException and Exception with RoundupException
John Rouillard <rouilj@ieee.org>
parents: 6005
diff changeset
8 pass
c177e7128dc9 issue2551083 Replace BaseException and Exception with RoundupException
John Rouillard <rouilj@ieee.org>
parents: 6005
diff changeset
9
c177e7128dc9 issue2551083 Replace BaseException and Exception with RoundupException
John Rouillard <rouilj@ieee.org>
parents: 6005
diff changeset
10 class LoginError(RoundupException):
4083
bbab97f8ffb2 XMLRPC improvements:
Stefan Seefeld <stefan@seefeld.name>
parents: 4066
diff changeset
11 pass
bbab97f8ffb2 XMLRPC improvements:
Stefan Seefeld <stefan@seefeld.name>
parents: 4066
diff changeset
12
6005
292c9dfd06bd flake8 formatting fixes.
John Rouillard <rouilj@ieee.org>
parents: 5264
diff changeset
13
6123
c177e7128dc9 issue2551083 Replace BaseException and Exception with RoundupException
John Rouillard <rouilj@ieee.org>
parents: 6005
diff changeset
14 class Unauthorised(RoundupException):
4083
bbab97f8ffb2 XMLRPC improvements:
Stefan Seefeld <stefan@seefeld.name>
parents: 4066
diff changeset
15 pass
bbab97f8ffb2 XMLRPC improvements:
Stefan Seefeld <stefan@seefeld.name>
parents: 4066
diff changeset
16
6123
c177e7128dc9 issue2551083 Replace BaseException and Exception with RoundupException
John Rouillard <rouilj@ieee.org>
parents: 6005
diff changeset
17 class RejectBase(RoundupException):
c177e7128dc9 issue2551083 Replace BaseException and Exception with RoundupException
John Rouillard <rouilj@ieee.org>
parents: 6005
diff changeset
18 pass
6005
292c9dfd06bd flake8 formatting fixes.
John Rouillard <rouilj@ieee.org>
parents: 5264
diff changeset
19
6123
c177e7128dc9 issue2551083 Replace BaseException and Exception with RoundupException
John Rouillard <rouilj@ieee.org>
parents: 6005
diff changeset
20 class Reject(RejectBase):
4083
bbab97f8ffb2 XMLRPC improvements:
Stefan Seefeld <stefan@seefeld.name>
parents: 4066
diff changeset
21 """An auditor may raise this exception when the current create or set
2129
3fd672293712 add and use Reject exception [SF#700265]
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
22 operation should be stopped.
3fd672293712 add and use Reject exception [SF#700265]
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
23
3fd672293712 add and use Reject exception [SF#700265]
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
24 It is up to the specific interface invoking the create or set to
3fd672293712 add and use Reject exception [SF#700265]
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
25 handle this exception sanely. For example:
3fd672293712 add and use Reject exception [SF#700265]
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
26
3fd672293712 add and use Reject exception [SF#700265]
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
27 - mailgw will trap and ignore Reject for file attachments and messages
3fd672293712 add and use Reject exception [SF#700265]
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
28 - cgi will trap and present the exception in a nice format
4083
bbab97f8ffb2 XMLRPC improvements:
Stefan Seefeld <stefan@seefeld.name>
parents: 4066
diff changeset
29 """
2129
3fd672293712 add and use Reject exception [SF#700265]
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
30 pass
3fd672293712 add and use Reject exception [SF#700265]
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
31
5004
494d255043c9 Display errors containing HTML with RejectRaw (issue2550847)
John Kristensen <john@jerrykan.com>
parents: 4083
diff changeset
32
494d255043c9 Display errors containing HTML with RejectRaw (issue2550847)
John Kristensen <john@jerrykan.com>
parents: 4083
diff changeset
33 class RejectRaw(Reject):
494d255043c9 Display errors containing HTML with RejectRaw (issue2550847)
John Kristensen <john@jerrykan.com>
parents: 4083
diff changeset
34 """
494d255043c9 Display errors containing HTML with RejectRaw (issue2550847)
John Kristensen <john@jerrykan.com>
parents: 4083
diff changeset
35 Performs the same function as Reject, except HTML in the message is not
494d255043c9 Display errors containing HTML with RejectRaw (issue2550847)
John Kristensen <john@jerrykan.com>
parents: 4083
diff changeset
36 escaped when displayed to the user.
494d255043c9 Display errors containing HTML with RejectRaw (issue2550847)
John Kristensen <john@jerrykan.com>
parents: 4083
diff changeset
37 """
494d255043c9 Display errors containing HTML with RejectRaw (issue2550847)
John Kristensen <john@jerrykan.com>
parents: 4083
diff changeset
38 pass
494d255043c9 Display errors containing HTML with RejectRaw (issue2550847)
John Kristensen <john@jerrykan.com>
parents: 4083
diff changeset
39
494d255043c9 Display errors containing HTML with RejectRaw (issue2550847)
John Kristensen <john@jerrykan.com>
parents: 4083
diff changeset
40
4066
042ace5ddb7c Move 'UsageError' definition from roundup.admin to roundup.exceptions.
Stefan Seefeld <stefan@seefeld.name>
parents: 2129
diff changeset
41 class UsageError(ValueError):
042ace5ddb7c Move 'UsageError' definition from roundup.admin to roundup.exceptions.
Stefan Seefeld <stefan@seefeld.name>
parents: 2129
diff changeset
42 pass
042ace5ddb7c Move 'UsageError' definition from roundup.admin to roundup.exceptions.
Stefan Seefeld <stefan@seefeld.name>
parents: 2129
diff changeset
43
2129
3fd672293712 add and use Reject exception [SF#700265]
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
44 # vim: set filetype=python ts=4 sw=4 et si

Roundup Issue Tracker: http://roundup-tracker.org/