mirror of
https://github.com/Kozea/Radicale.git
synced 2025-09-12 20:30:57 +00:00
Allow attach custom storage backend
This commit is contained in:
parent
a91a7790c5
commit
3b0328ca1e
6 changed files with 66 additions and 6 deletions
|
@ -81,6 +81,7 @@ INITIAL_CONFIG = {
|
|||
"file": "~/.config/radicale/rights"},
|
||||
"storage": {
|
||||
"type": "filesystem",
|
||||
"custom_handler": "",
|
||||
"filesystem_folder": os.path.expanduser(
|
||||
"~/.config/radicale/collections"),
|
||||
"database_url": ""},
|
||||
|
|
|
@ -23,15 +23,20 @@ This module loads the storage backend, according to the storage
|
|||
configuration.
|
||||
|
||||
"""
|
||||
|
||||
import sys
|
||||
from .. import config, ical
|
||||
|
||||
|
||||
def load():
|
||||
"""Load list of available storage managers."""
|
||||
storage_type = config.get("storage", "type")
|
||||
root_module = __import__(
|
||||
"storage.%s" % storage_type, globals=globals(), level=2)
|
||||
module = getattr(root_module, storage_type)
|
||||
if storage_type == "custom":
|
||||
storage_module = config.get("storage", "custom_handler")
|
||||
__import__(storage_module)
|
||||
module = sys.modules[storage_module]
|
||||
else:
|
||||
root_module = __import__(
|
||||
"storage.%s" % storage_type, globals=globals(), level=2)
|
||||
module = getattr(root_module, storage_type)
|
||||
ical.Collection = module.Collection
|
||||
return module
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue