config.py 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. from ConfigParser import RawConfigParser as ConfigParser
  25. _config = ConfigParser()
  26. get = _config.get
  27. set = _config.set
  28. getboolean = _config.getboolean
  29. getint = _config.getint
  30. getfloat = _config.getfloat
  31. options = _config.options
  32. items = _config.items
  33. _initial = {
  34. "server": {
  35. "type": "http",
  36. "certificate": "/etc/apache2/ssl/server.crt",
  37. "privatekey": "/etc/apache2/ssl/server.key",
  38. "log": "/var/www/radicale/server.log",
  39. "port": "5232",
  40. },
  41. "encoding": {
  42. "request": "utf-8",
  43. "stock": "utf-8",
  44. },
  45. "namespace": {
  46. "C": "urn:ietf:params:xml:ns:caldav",
  47. "D": "DAV:",
  48. "CS": "http://calendarserver.org/ns/",
  49. },
  50. "status": {
  51. "200": "HTTP/1.1 200 OK",
  52. "204": "HTTP/1.1 204 No Content",
  53. },
  54. "acl": {
  55. "type": "fake",
  56. "filename": "/etc/radicale/users",
  57. "user": "radicale",
  58. },
  59. "support": {
  60. "type": "plain",
  61. "folder": "~/.config/radicale",
  62. "calendar": "radicale/calendar",
  63. },
  64. }
  65. for section, values in _initial.iteritems():
  66. _config.add_section(section)
  67. for key, value in values.iteritems():
  68. _config.set(section, key, value)
  69. # TODO: Use abstract filename for other platforms
  70. _config.read("/etc/radicale/config")