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]
# Rights backend # Rights backend
# Value: regex | custom
backend = regex
# Rights management method
# Value: None | owner_only | owner_write | from_file | custom # Value: None | owner_only | owner_write | from_file | custom
type = None type = None

View File

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

View File

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