__init__.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. # This file is part of Radicale Server - Calendar Server
  2. # Copyright © 2012-2016 Guillaume Ayoub
  3. #
  4. # This library is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation, either version 3 of the License, or
  7. # (at your option) any later version.
  8. #
  9. # This library is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with Radicale. If not, see <http://www.gnu.org/licenses/>.
  16. """
  17. Storage backends.
  18. This module loads the storage backend, according to the storage
  19. configuration.
  20. """
  21. import sys
  22. from .. import config, ical
  23. def load():
  24. """Load list of available storage managers."""
  25. storage_type = config.get("storage", "type")
  26. if storage_type == "custom":
  27. storage_module = config.get("storage", "custom_handler")
  28. __import__(storage_module)
  29. module = sys.modules[storage_module]
  30. else:
  31. root_module = __import__(
  32. "storage.%s" % storage_type, globals=globals(), level=2)
  33. module = getattr(root_module, storage_type)
  34. ical.Collection = module.Collection
  35. return module