svn: Update and add doc strings and comments.
This commit is contained in:
parent
0bc70c1bc6
commit
70aca495eb
4 changed files with 38 additions and 10 deletions
|
|
@ -35,12 +35,14 @@ def includeme(config):
|
|||
_sanitize_settings_and_apply_defaults(settings)
|
||||
|
||||
if settings[keys.generate_config]:
|
||||
log.error('Add subscriber')
|
||||
config.add_subscriber(
|
||||
generate_mod_dav_svn_config, events.RepoGroupEvent)
|
||||
|
||||
|
||||
def _sanitize_settings_and_apply_defaults(settings):
|
||||
"""
|
||||
Set defaults, convert to python types and validate settings.
|
||||
"""
|
||||
# Convert bool settings from string to bool.
|
||||
settings[keys.generate_config] = str2bool(
|
||||
settings.get(keys.generate_config, 'false'))
|
||||
|
|
@ -53,9 +55,9 @@ def _sanitize_settings_and_apply_defaults(settings):
|
|||
settings.setdefault(keys.parent_path_root, None)
|
||||
|
||||
# Append path separator to paths.
|
||||
settings[keys.location_root] = _append_slash(
|
||||
settings[keys.location_root] = _append_path_sep(
|
||||
settings[keys.location_root])
|
||||
settings[keys.parent_path_root] = _append_slash(
|
||||
settings[keys.parent_path_root] = _append_path_sep(
|
||||
settings[keys.parent_path_root])
|
||||
|
||||
# Validate settings.
|
||||
|
|
@ -63,7 +65,10 @@ def _sanitize_settings_and_apply_defaults(settings):
|
|||
assert settings[keys.config_file_path] is not None
|
||||
|
||||
|
||||
def _append_slash(path):
|
||||
def _append_path_sep(path):
|
||||
"""
|
||||
Append the path separator if missing.
|
||||
"""
|
||||
if isinstance(path, basestring) and not path.endswith(os.path.sep):
|
||||
path += os.path.sep
|
||||
return path
|
||||
|
|
|
|||
|
|
@ -19,7 +19,8 @@
|
|||
# and proprietary license terms, please see https://rhodecode.com/licenses/
|
||||
|
||||
|
||||
# Settings keys used in the ini file.
|
||||
# Definition of setting keys used to configure this module. Defined here to
|
||||
# avoid repetition of keys throughout the module.
|
||||
config_file_path = 'svn.proxy.config_file_path'
|
||||
generate_config = 'svn.proxy.generate_config'
|
||||
list_parent_path = 'svn.proxy.list_parent_path'
|
||||
|
|
|
|||
|
|
@ -31,11 +31,25 @@ log = logging.getLogger(__name__)
|
|||
|
||||
|
||||
def generate_mod_dav_svn_config(event):
|
||||
_generate(event.request)
|
||||
"""
|
||||
Subscriber to the `rhodcode.events.RepoGroupEvent`. This triggers the
|
||||
automatic generation of mod_dav_svn config file on repository group
|
||||
changes.
|
||||
"""
|
||||
_generate(event.request.registry.settings)
|
||||
|
||||
|
||||
def _generate(request):
|
||||
settings = request.registry.settings
|
||||
def _generate(settings):
|
||||
"""
|
||||
Generate the configuration file for use with subversion's mod_dav_svn
|
||||
module. The configuration has to contain a <Location> block for each
|
||||
available repository group because the mod_dav_svn module does not support
|
||||
repositories organized in sub folders.
|
||||
|
||||
Currently this is only used by the subscriber above. If we extend this
|
||||
to include it as API method and in the web interface this should be moved
|
||||
to an appropriate place.
|
||||
"""
|
||||
filepath = settings[keys.config_file_path]
|
||||
repository_root = settings[keys.parent_path_root]
|
||||
list_parent_path = settings[keys.list_parent_path]
|
||||
|
|
|
|||
|
|
@ -1,5 +1,13 @@
|
|||
# This file is auto generated by RhodeCode. It contains the configuration for
|
||||
# use with mod_dav_svn.
|
||||
# Auto generated configuration for use with the Apache mod_dav_svn module.
|
||||
|
||||
# The mod_dav_svn module does not support subversion repositories which are
|
||||
# organized in subfolders. To support the repository groups of RhodeCode it is
|
||||
# required to provide a <Location> block for each group pointing to the
|
||||
# repository group sub folder.
|
||||
|
||||
# To ease the configuration RhodeCode auto generates this file whenever a
|
||||
# repository group is created/changed/deleted. Auto generation can be configured
|
||||
# in the ini file.
|
||||
|
||||
<Location ${location_root}>
|
||||
DAV svn
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue