mirror of
https://github.com/Kozea/Radicale.git
synced 2025-08-10 18:40:53 +00:00
Allow callable in configuration for plugin.type
Example: ```python3 \# Load default configuration my_config = config.load() \# Pass a class directly my_config.update({"auth": {"type": MyAuth}}) \# Pass an object directly my_rights = MyRights() my_config.update({"rights": {"type": lambda config: my_rights}}) app = Application(my_config) ````
This commit is contained in:
parent
72f8b29190
commit
9c622b57d5
3 changed files with 20 additions and 4 deletions
|
@ -81,6 +81,12 @@ def list_of_ip_address(value):
|
|||
return [ip_address(s.strip()) for s in value.split(",")]
|
||||
|
||||
|
||||
def str_or_callable(value):
|
||||
if callable(value):
|
||||
return value
|
||||
return str(value)
|
||||
|
||||
|
||||
def unspecified_type(value):
|
||||
return value
|
||||
|
||||
|
@ -150,7 +156,7 @@ DEFAULT_CONFIG_SCHEMA = OrderedDict([
|
|||
("type", {
|
||||
"value": "none",
|
||||
"help": "authentication method",
|
||||
"type": str,
|
||||
"type": str_or_callable,
|
||||
"internal": auth.INTERNAL_TYPES}),
|
||||
("htpasswd_filename", {
|
||||
"value": "/etc/radicale/users",
|
||||
|
@ -172,7 +178,7 @@ DEFAULT_CONFIG_SCHEMA = OrderedDict([
|
|||
("type", {
|
||||
"value": "owner_only",
|
||||
"help": "rights backend",
|
||||
"type": str,
|
||||
"type": str_or_callable,
|
||||
"internal": rights.INTERNAL_TYPES}),
|
||||
("file", {
|
||||
"value": "/etc/radicale/rights",
|
||||
|
@ -182,7 +188,7 @@ DEFAULT_CONFIG_SCHEMA = OrderedDict([
|
|||
("type", {
|
||||
"value": "multifilesystem",
|
||||
"help": "storage backend",
|
||||
"type": str,
|
||||
"type": str_or_callable,
|
||||
"internal": storage.INTERNAL_TYPES}),
|
||||
("filesystem_folder", {
|
||||
"value": "/var/lib/radicale/collections",
|
||||
|
@ -204,7 +210,7 @@ DEFAULT_CONFIG_SCHEMA = OrderedDict([
|
|||
("type", {
|
||||
"value": "internal",
|
||||
"help": "web interface backend",
|
||||
"type": str,
|
||||
"type": str_or_callable,
|
||||
"internal": web.INTERNAL_TYPES})])),
|
||||
("logging", OrderedDict([
|
||||
("level", {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue