diff --git a/config b/config index 411d49b..93f38b5 100644 --- a/config +++ b/config @@ -105,12 +105,15 @@ committer = Firstname Lastname [rights] # Rights backend # Value: regex -backend = "regex" +backend = regex # Rights management method -# Value: None | owner_only | owner_write | from_file +# Value: None | owner_only | owner_write | from_file | custom type = None +# Rights custom handler +custom_handler = + # File for rights management from_file file = ~/.config/radicale/rights diff --git a/radicale/config.py b/radicale/config.py index 53a3346..eecd42c 100644 --- a/radicale/config.py +++ b/radicale/config.py @@ -78,6 +78,7 @@ INITIAL_CONFIG = { "rights": { "backend": "regex", "type": "None", + "custom_handler": "", "file": "~/.config/radicale/rights"}, "storage": { "type": "filesystem", diff --git a/radicale/rights/__init__.py b/radicale/rights/__init__.py index 5e9770f..789953b 100644 --- a/radicale/rights/__init__.py +++ b/radicale/rights/__init__.py @@ -31,9 +31,14 @@ from .. import config def load(): """Load list of available storage managers.""" storage_type = config.get("rights", "backend") - root_module = __import__( - "rights.%s" % storage_type, globals=globals(), level=2) - module = getattr(root_module, storage_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) sys.modules[__name__].authorized = module.authorized return module