Code Repositories xandikos / f40e1a7
Support AUTORECREATE variable in wsgi mode. Fixes #57 Jelmer Vernooń≥ 3 years ago
3 changed file(s) with 25 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
88 module = xandikos.wsgi:app
99 env = XANDIKOSPATH=$HOME/dav
1010 env = CURRENT_USER_PRINCIPAL=/dav/user1/
11 # Set AUTOCREATE to have Xandikos create default CalDAV/CardDAV
12 # collections if they don't yet exist. Possible values:
13 # - principal: just create the current user principal
14 # - defaults: create the principal and default calendar and contacts
15 # collections. (recommended)
16 env = AUTOCREATE=defaults
1010 umask = 022
1111 env = XANDIKOSPATH=/var/lib/xandikos/collections
1212 env = CURRENT_USER_PRINCIPAL=/user/
13 # Set AUTOCREATE to have Xandikos create default CalDAV/CardDAV
14 # collections if they don't yet exist. Possible values:
15 # - principal: just create the current user principal
16 # - defaults: create the principal and default calendar and contacts
17 # collections. (recommended)
18 env = AUTOCREATE=defaults
2626
2727 backend = XandikosBackend(path=os.environ['XANDIKOSPATH'])
2828 if not os.path.isdir(backend.path):
29 logging.warning('%r does not exist.', backend.path)
29 if os.getenv('AUTOCREATE'):
30 os.makedirs(os.environ['XANDIKOSPATH'])
31 else:
32 logging.warning('%r does not exist.', backend.path)
3033
3134 current_user_principal = os.environ.get('CURRENT_USER_PRINCIPAL', '/user/')
3235 if not backend.get_resource(current_user_principal):
33 logging.warning(
34 'default user principal \'%s\' does not exist. Create directory %s?',
35 current_user_principal, backend._map_to_file_path(
36 if os.getenv('AUTOCREATE'):
37 backend.create_principal(
38 current_user_principal,
39 create_defaults=os.environ['AUTOCREATE'] == 'defaults')
40 else:
41 logging.warning(
42 'default user principal \'%s\' does not exist. Create directory %s'
43 ' or set AUTOCREATE variable?',
44 current_user_principal, backend._map_to_file_path(
3645 current_user_principal))
3746
3847 backend._mark_as_principal(current_user_principal)