Allow additional config options for external plugins

This commit is contained in:
Unrud 2017-06-21 09:48:57 +02:00
parent 31377bad40
commit 276de4fd3a
6 changed files with 28 additions and 4 deletions

View File

@ -58,6 +58,8 @@ def run():
kwargs["dest"] = "{0}_{1}".format(section, option)
groups[group].append(kwargs["dest"])
del kwargs["value"]
if "internal" in kwargs:
del kwargs["internal"]
if kwargs["type"] == bool:
del kwargs["type"]

View File

@ -60,6 +60,9 @@ import hmac
import os
from importlib import import_module
INTERNAL_TYPES = ("None", "none", "remote_user", "http_x_remote_user",
"htpasswd")
def load(configuration, logger):
"""Load the authentication manager chosen in configuration."""

View File

@ -28,6 +28,8 @@ import os
from collections import OrderedDict
from configparser import RawConfigParser as ConfigParser
from . import auth, rights, storage, web
def positive_int(value):
value = int(value)
@ -128,7 +130,8 @@ INITIAL_CONFIG = OrderedDict([
("type", {
"value": "none",
"help": "authentication method",
"type": str}),
"type": str,
"internal": auth.INTERNAL_TYPES}),
("htpasswd_filename", {
"value": "/etc/radicale/users",
"help": "htpasswd filename",
@ -145,7 +148,8 @@ INITIAL_CONFIG = OrderedDict([
("type", {
"value": "owner_only",
"help": "rights backend",
"type": str}),
"type": str,
"internal": rights.INTERNAL_TYPES}),
("file", {
"value": "/etc/radicale/rights",
"help": "file for rights management from_file",
@ -154,7 +158,8 @@ INITIAL_CONFIG = OrderedDict([
("type", {
"value": "multifilesystem",
"help": "storage backend",
"type": str}),
"type": str,
"internal": storage.INTERNAL_TYPES}),
("filesystem_folder", {
"value": os.path.expanduser(
"/var/lib/radicale/collections"),
@ -184,7 +189,8 @@ INITIAL_CONFIG = OrderedDict([
("type", {
"value": "internal",
"help": "web interface backend",
"type": str})])),
"type": str,
"internal": web.INTERNAL_TYPES})])),
("logging", OrderedDict([
("config", {
"value": "",
@ -229,8 +235,14 @@ def load(paths=(), extra_config=None, ignore_missing_paths=True):
continue
if section not in INITIAL_CONFIG:
raise RuntimeError("Invalid section %r in config" % section)
allow_extra_options = ("type" in INITIAL_CONFIG[section] and
config.get(section, "type") not in
INITIAL_CONFIG[section]["type"].get("internal",
()))
for option in config[section]:
if option not in INITIAL_CONFIG[section]:
if allow_extra_options:
continue
raise RuntimeError("Invalid option %r in section %r in "
"config" % (option, section))
type_ = INITIAL_CONFIG[section][option]["type"]

View File

@ -45,6 +45,9 @@ from importlib import import_module
from . import storage
INTERNAL_TYPES = ("None", "none", "authenticated", "owner_write", "owner_only",
"from_file")
def load(configuration, logger):
"""Load the rights manager chosen in configuration."""

View File

@ -88,6 +88,8 @@ if os.name == "nt":
elif os.name == "posix":
import fcntl
INTERNAL_TYPES = ("multifilesystem",)
def load(configuration, logger):
"""Load the storage manager chosen in configuration."""

View File

@ -44,6 +44,8 @@ MIMETYPES = {
".xml": "text/xml"}
FALLBACK_MIMETYPE = "application/octet-stream"
INTERNAL_TYPES = ("None", "none", "internal")
def load(configuration, logger):
"""Load the web module chosen in configuration."""