Remove the backend/type split for rights in configuration

This commit is contained in:
Guillaume Ayoub 2014-02-05 14:11:40 +01:00
parent f6a6e77fb0
commit f9ce1d0e6d
3 changed files with 4 additions and 10 deletions

4
config
View File

@ -104,10 +104,6 @@ committer = Radicale <radicale@example.com>
[rights]
# Rights backend
# Value: regex | custom
backend = regex
# Rights management method
# Value: None | owner_only | owner_write | from_file | custom
type = None

View File

@ -76,7 +76,6 @@ INITIAL_CONFIG = {
"git": {
"committer": "Radicale <radicale@example.com>"},
"rights": {
"backend": "regex",
"type": "None",
"custom_handler": "",
"file": "~/.config/radicale/rights"},

View File

@ -30,15 +30,14 @@ from .. import config
def load():
"""Load list of available storage managers."""
storage_type = config.get("rights", "backend")
if storage_type == 'custom':
storage_type = config.get("rights", "type")
if storage_type == "custom":
rights_module = config.get("rights", "custom_handler")
__import__(rights_module)
module = sys.modules[rights_module]
else:
root_module = __import__(
"rights.%s" % storage_type, globals=globals(), level=2)
module = getattr(root_module, storage_type)
root_module = __import__("rights.regex", globals=globals(), level=2)
module = root_module.regex
sys.modules[__name__].authorized = module.authorized
return module