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:
@@ -23,6 +23,9 @@ from radicale.log import logger
|
||||
|
||||
def load_plugin(internal_types, module_name, class_name, configuration):
|
||||
type_ = configuration.get(module_name, "type")
|
||||
if callable(type_):
|
||||
logger.info("%s type is %r", module_name, type_)
|
||||
return type_(configuration)
|
||||
if type_ in internal_types:
|
||||
module = "radicale.%s.%s" % (module_name, type_)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user