##// END OF EJS Templates
svn: Update and add doc strings and comments.
Martin Bornhold -
r560:01b438e0 default
parent child Browse files
Show More
@@ -35,12 +35,14 b' def includeme(config):'
35 _sanitize_settings_and_apply_defaults(settings)
35 _sanitize_settings_and_apply_defaults(settings)
36
36
37 if settings[keys.generate_config]:
37 if settings[keys.generate_config]:
38 log.error('Add subscriber')
39 config.add_subscriber(
38 config.add_subscriber(
40 generate_mod_dav_svn_config, events.RepoGroupEvent)
39 generate_mod_dav_svn_config, events.RepoGroupEvent)
41
40
42
41
43 def _sanitize_settings_and_apply_defaults(settings):
42 def _sanitize_settings_and_apply_defaults(settings):
43 """
44 Set defaults, convert to python types and validate settings.
45 """
44 # Convert bool settings from string to bool.
46 # Convert bool settings from string to bool.
45 settings[keys.generate_config] = str2bool(
47 settings[keys.generate_config] = str2bool(
46 settings.get(keys.generate_config, 'false'))
48 settings.get(keys.generate_config, 'false'))
@@ -53,9 +55,9 b' def _sanitize_settings_and_apply_default'
53 settings.setdefault(keys.parent_path_root, None)
55 settings.setdefault(keys.parent_path_root, None)
54
56
55 # Append path separator to paths.
57 # Append path separator to paths.
56 settings[keys.location_root] = _append_slash(
58 settings[keys.location_root] = _append_path_sep(
57 settings[keys.location_root])
59 settings[keys.location_root])
58 settings[keys.parent_path_root] = _append_slash(
60 settings[keys.parent_path_root] = _append_path_sep(
59 settings[keys.parent_path_root])
61 settings[keys.parent_path_root])
60
62
61 # Validate settings.
63 # Validate settings.
@@ -63,7 +65,10 b' def _sanitize_settings_and_apply_default'
63 assert settings[keys.config_file_path] is not None
65 assert settings[keys.config_file_path] is not None
64
66
65
67
66 def _append_slash(path):
68 def _append_path_sep(path):
69 """
70 Append the path separator if missing.
71 """
67 if isinstance(path, basestring) and not path.endswith(os.path.sep):
72 if isinstance(path, basestring) and not path.endswith(os.path.sep):
68 path += os.path.sep
73 path += os.path.sep
69 return path
74 return path
@@ -19,7 +19,8 b''
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20
20
21
21
22 # Settings keys used in the ini file.
22 # Definition of setting keys used to configure this module. Defined here to
23 # avoid repetition of keys throughout the module.
23 config_file_path = 'svn.proxy.config_file_path'
24 config_file_path = 'svn.proxy.config_file_path'
24 generate_config = 'svn.proxy.generate_config'
25 generate_config = 'svn.proxy.generate_config'
25 list_parent_path = 'svn.proxy.list_parent_path'
26 list_parent_path = 'svn.proxy.list_parent_path'
@@ -31,11 +31,25 b' log = logging.getLogger(__name__)'
31
31
32
32
33 def generate_mod_dav_svn_config(event):
33 def generate_mod_dav_svn_config(event):
34 _generate(event.request)
34 """
35 Subscriber to the `rhodcode.events.RepoGroupEvent`. This triggers the
36 automatic generation of mod_dav_svn config file on repository group
37 changes.
38 """
39 _generate(event.request.registry.settings)
35
40
36
41
37 def _generate(request):
42 def _generate(settings):
38 settings = request.registry.settings
43 """
44 Generate the configuration file for use with subversion's mod_dav_svn
45 module. The configuration has to contain a <Location> block for each
46 available repository group because the mod_dav_svn module does not support
47 repositories organized in sub folders.
48
49 Currently this is only used by the subscriber above. If we extend this
50 to include it as API method and in the web interface this should be moved
51 to an appropriate place.
52 """
39 filepath = settings[keys.config_file_path]
53 filepath = settings[keys.config_file_path]
40 repository_root = settings[keys.parent_path_root]
54 repository_root = settings[keys.parent_path_root]
41 list_parent_path = settings[keys.list_parent_path]
55 list_parent_path = settings[keys.list_parent_path]
@@ -1,5 +1,13 b''
1 # This file is auto generated by RhodeCode. It contains the configuration for
1 # Auto generated configuration for use with the Apache mod_dav_svn module.
2 # use with mod_dav_svn.
2
3 # The mod_dav_svn module does not support subversion repositories which are
4 # organized in subfolders. To support the repository groups of RhodeCode it is
5 # required to provide a <Location> block for each group pointing to the
6 # repository group sub folder.
7
8 # To ease the configuration RhodeCode auto generates this file whenever a
9 # repository group is created/changed/deleted. Auto generation can be configured
10 # in the ini file.
3
11
4 <Location ${location_root}>
12 <Location ${location_root}>
5 DAV svn
13 DAV svn
General Comments 0
You need to be logged in to leave comments. Login now