##// END OF EJS Templates
svn-support: Move try/catch block up to subscriber and also DB interaction.
Martin Bornhold -
r831:64e22267 default
parent child Browse files
Show More
@@ -18,14 +18,27 b''
18 18 # RhodeCode Enterprise Edition, including its added features, Support services,
19 19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20 20
21 import logging
21 22
23 from rhodecode.model.settings import SettingsModel
22 24 from .utils import generate_mod_dav_svn_config
23 25
24 26
27 log = logging.getLogger(__name__)
28
29
25 30 def generate_config_subscriber(event):
26 31 """
27 32 Subscriber to the `rhodcode.events.RepoGroupEvent`. This triggers the
28 33 automatic generation of mod_dav_svn config file on repository group
29 34 changes.
30 35 """
31 generate_mod_dav_svn_config(event.request.registry.settings)
36 try:
37 parent_path_root = SettingsModel().get_ui_by_section_and_key(
38 'paths', '/').ui_value
39 generate_mod_dav_svn_config(
40 settings=event.request.registry.settings,
41 parent_path_root=parent_path_root)
42 except Exception:
43 log.exception(
44 'Exception while generating subversion mod_dav_svn configuration.')
@@ -26,22 +26,19 b' from pyramid.renderers import render'
26 26
27 27 from rhodecode.lib.utils import get_rhodecode_realm
28 28 from rhodecode.model.db import RepoGroup
29 from rhodecode.model.settings import SettingsModel
30 29 from . import config_keys
31 30
32 31
33 32 log = logging.getLogger(__name__)
34 33
35 34
36 def generate_mod_dav_svn_config(settings):
35 def generate_mod_dav_svn_config(settings, parent_path_root):
37 36 """
38 37 Generate the configuration file for use with subversion's mod_dav_svn
39 38 module. The configuration has to contain a <Location> block for each
40 39 available repository group because the mod_dav_svn module does not support
41 40 repositories organized in sub folders.
42 41 """
43 parent_path_root = SettingsModel().get_ui_by_section_and_key(
44 'paths', '/').ui_value
45 42 config = _render_mod_dav_svn_config(
46 43 parent_path_root=parent_path_root,
47 44 list_parent_path=settings[config_keys.list_parent_path],
@@ -77,12 +74,7 b' def _render_mod_dav_svn_config('
77 74
78 75 def _write_mod_dav_svn_config(config, filepath):
79 76 """
80 Write mod_dav_svn config to file. Log on exceptions but do not raise.
77 Write mod_dav_svn config to file.
81 78 """
82 try:
83 with codecs.open(filepath, 'w', encoding='utf-8') as f:
84 f.write(config)
85 except Exception:
86 log.exception(
87 'Exception while writing mod_dav_svn configuration to '
88 '"%s"', filepath)
79 with codecs.open(filepath, 'w', encoding='utf-8') as f:
80 f.write(config)
General Comments 0
You need to be logged in to leave comments. Login now