config.py 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. # -*- coding: utf-8 -*-
  2. #
  3. # This file is part of Radicale Server - Calendar Server
  4. # Copyright © 2008-2010 Guillaume Ayoub
  5. # Copyright © 2008 Nicolas Kandel
  6. # Copyright © 2008 Pascal Halter
  7. #
  8. # This library is free software: you can redistribute it and/or modify
  9. # it under the terms of the GNU General Public License as published by
  10. # the Free Software Foundation, either version 3 of the License, or
  11. # (at your option) any later version.
  12. #
  13. # This library is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. # GNU General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU General Public License
  19. # along with Radicale. If not, see <http://www.gnu.org/licenses/>.
  20. """
  21. Radicale configuration module.
  22. Give a configparser-like interface to read and write configuration.
  23. """
  24. try:
  25. from configparser import RawConfigParser as ConfigParser
  26. except ImportError:
  27. from ConfigParser import RawConfigParser as ConfigParser
  28. _config = ConfigParser()
  29. get = _config.get
  30. set = _config.set
  31. getboolean = _config.getboolean
  32. getint = _config.getint
  33. getfloat = _config.getfloat
  34. options = _config.options
  35. items = _config.items
  36. _initial = {
  37. "server": {
  38. "type": "http",
  39. "certificate": "/etc/apache2/ssl/server.crt",
  40. "privatekey": "/etc/apache2/ssl/server.key",
  41. "log": "/var/www/radicale/server.log",
  42. "port": "5232",
  43. },
  44. "encoding": {
  45. "request": "utf-8",
  46. "stock": "utf-8",
  47. },
  48. "namespace": {
  49. "C": "urn:ietf:params:xml:ns:caldav",
  50. "D": "DAV:",
  51. "CS": "http://calendarserver.org/ns/",
  52. },
  53. "status": {
  54. "200": "HTTP/1.1 200 OK",
  55. "204": "HTTP/1.1 204 No Content",
  56. },
  57. "acl": {
  58. "type": "fake",
  59. "filename": "/etc/radicale/users",
  60. "user": "radicale",
  61. },
  62. "support": {
  63. "type": "plain",
  64. "folder": "~/.config/radicale",
  65. "calendar": "radicale/calendar",
  66. },
  67. }
  68. for section, values in _initial.items():
  69. _config.add_section(section)
  70. for key, value in values.items():
  71. _config.set(section, key, value)
  72. # TODO: Use abstract filename for other platforms
  73. _config.read("/etc/radicale/config")