##// END OF EJS Templates
svn: Move path computation from themplate to python.
Martin Bornhold -
r570:bb5e4c7c default
parent child Browse files
Show More
@@ -1,64 +1,65 b''
1 1 # Auto generated configuration for use with the Apache mod_dav_svn module.
2 2 #
3 3 # WARNING: Make sure your Apache instance which runs the mod_dav_svn module is
4 4 # only accessible by RhodeCode. Otherwise everyone is able to browse
5 5 # the repositories or run subversion operations (checkout/commit/etc.).
6 6 #
7 7 # The mod_dav_svn module does not support subversion repositories which are
8 8 # organized in subfolders. To support the repository groups of RhodeCode it is
9 9 # required to provide a <Location> block for each group pointing to the
10 10 # repository group sub folder.
11 11 #
12 12 # To ease the configuration RhodeCode auto generates this file whenever a
13 13 # repository group is created/changed/deleted. Auto generation can be configured
14 14 # in the ini file.
15 15 #
16 16 # To include this configuration into your apache config you can use the
17 17 # `Include` directive. See the following example snippet of a virtual host how
18 18 # to include this configuration file.
19 19 #
20 20 # <VirtualHost *:8080>
21 21 # ServerAdmin webmaster@localhost
22 22 # DocumentRoot /var/www/html
23 23 # ErrorLog ${'${APACHE_LOG_DIR}'}/error.log
24 24 # CustomLog ${'${APACHE_LOG_DIR}'}/access.log combined
25 25 # Include /path/to/generated/mod_dav_svn.conf
26 26 # </VirtualHost>
27 27
28 28
29 29 <Location ${location_root}>
30 30 # The mod_dav_svn module takes the username from the apache request object.
31 31 # Without authorization this will be empty and no username is logged for the
32 32 # transactions. This will result in "(no author)" for each revision. The
33 33 # following directives implement a fake authentication that allows every
34 34 # username/password combination.
35 35 AuthType Basic
36 36 AuthName "Subversion proxy"
37 37 AuthBasicProvider anon
38 38 Anonymous *
39 39 Require valid-user
40 40
41 41 DAV svn
42 42 SVNParentPath ${parent_path_root}
43 43 SVNListParentPath ${'On' if svn_list_parent_path else 'Off'}
44 44
45 45 Allow from all
46 46 Order allow,deny
47 47 </Location>
48 48
49 % for repo_group in repo_groups:
50 <Location ${location_root_stripped}${repo_group.full_path}>
49 % for location, parent_path in repo_group_paths:
50
51 <Location ${location}>
51 52 AuthType Basic
52 53 AuthName "Subversion proxy"
53 54 AuthBasicProvider anon
54 55 Anonymous *
55 56 Require valid-user
56 57
57 58 DAV svn
58 SVNParentPath ${parent_path_root_stripped}${repo_group.full_path}
59 SVNParentPath ${parent_path}
59 60 SVNListParentPath ${'On' if svn_list_parent_path else 'Off'}
60 61
61 62 Allow from all
62 63 Order allow,deny
63 64 </Location>
64 65 % endfor
@@ -1,55 +1,62 b''
1 1 # -*- coding: utf-8 -*-
2 2
3 3 # Copyright (C) 2016-2016 RhodeCode GmbH
4 4 #
5 5 # This program is free software: you can redistribute it and/or modify
6 6 # it under the terms of the GNU Affero General Public License, version 3
7 7 # (only), as published by the Free Software Foundation.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU Affero General Public License
15 15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 16 #
17 17 # This program is dual-licensed. If you wish to learn more about the
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 21 import os
22 22
23 23 from pyramid.renderers import render
24 24
25 25 from rhodecode.model.db import RepoGroup
26 26 from . import config_keys
27 27
28 28
29 29 def generate_mod_dav_svn_config(settings):
30 30 """
31 31 Generate the configuration file for use with subversion's mod_dav_svn
32 32 module. The configuration has to contain a <Location> block for each
33 33 available repository group because the mod_dav_svn module does not support
34 34 repositories organized in sub folders.
35 35 """
36 36 filepath = settings[config_keys.config_file_path]
37 37 parent_path_root = settings[config_keys.parent_path_root]
38 38 list_parent_path = settings[config_keys.list_parent_path]
39 39 location_root = settings[config_keys.location_root]
40 40
41 # Render the configuration to string.
42 template = 'rhodecode:svn_support/templates/mod-dav-svn.conf.mako'
41 # Prepare render context.
42 repo_group_paths = []
43 for repo_group in RepoGroup.get_all_repo_groups():
44 group_path = repo_group.full_path_splitted
45 location = os.path.join(location_root, *group_path)
46 parent_path = os.path.join(parent_path_root, *group_path)
47 repo_group_paths.append((location, parent_path))
48
43 49 context = {
44 50 'location_root': location_root,
45 'location_root_stripped': location_root.rstrip(os.path.sep),
46 51 'parent_path_root': parent_path_root,
47 'parent_path_root_stripped': parent_path_root.rstrip(os.path.sep),
48 'repo_groups': RepoGroup.get_all_repo_groups(),
52 'repo_group_paths': repo_group_paths,
49 53 'svn_list_parent_path': list_parent_path,
50 54 }
55
56 # Render the configuration template to string.
57 template = 'rhodecode:svn_support/templates/mod-dav-svn.conf.mako'
51 58 mod_dav_svn_config = render(template, context)
52 59
53 60 # Write configuration to file.
54 61 with open(filepath, 'w') as file_:
55 62 file_.write(mod_dav_svn_config)
General Comments 0
You need to be logged in to leave comments. Login now