__init__.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # This file is part of Radicale Server - Calendar Server
  2. # Copyright © 2017-2018 Unrud <unrud@outlook.com>
  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. The web module for the website at ``/.web``.
  18. Take a look at the class ``BaseWeb`` if you want to implement your own.
  19. """
  20. from radicale import utils
  21. INTERNAL_TYPES = ("none", "internal")
  22. def load(configuration):
  23. """Load the web module chosen in configuration."""
  24. return utils.load_plugin(INTERNAL_TYPES, "web", "Web", configuration)
  25. class BaseWeb:
  26. def __init__(self, configuration):
  27. """Initialize BaseWeb.
  28. ``configuration`` see ``radicale.config`` module.
  29. The ``configuration`` must not change during the lifetime of
  30. this object, it is kept as an internal reference.
  31. """
  32. self.configuration = configuration
  33. def get(self, environ, base_prefix, path, user):
  34. """GET request.
  35. ``base_prefix`` is sanitized and never ends with "/".
  36. ``path`` is sanitized and always starts with "/.web"
  37. ``user`` is empty for anonymous users.
  38. """
  39. raise NotImplementedError