simplevcs: fixed logic of extraction of base_path

This commit is contained in:
Marcin Kuzminski 2017-11-16 15:59:11 +01:00
parent 3fa0e3ab2f
commit 4d9fa48377
2 changed files with 18 additions and 6 deletions

View file

@ -122,7 +122,11 @@ class SimpleVCS(object):
@property
def base_path(self):
return self.repo_vcs_config.get(*VcsSettingsModel.PATH_SETTING)
settings_path = self.repo_vcs_config.get(*VcsSettingsModel.PATH_SETTING)
if not settings_path:
# try, maybe we passed in explicitly as config option
settings_path = self.config.get('base_path')
return settings_path
def set_repo_names(self, environ):
"""

View file

@ -181,7 +181,11 @@ class VCSMiddleware(object):
"""
returns serialized VcsSettings
"""
return VcsSettingsModel(repo=repo_name).get_ui_settings_as_config_obj()
try:
return VcsSettingsModel(
repo=repo_name).get_ui_settings_as_config_obj()
except Exception:
pass
def wrap_in_gzip_if_enabled(self, app, config):
if self.use_gzip:
@ -209,6 +213,14 @@ class VCSMiddleware(object):
# Set acl, url and vcs repo names.
vcs_handler.set_repo_names(environ)
# register repo config back to the handler
vcs_conf = self.vcs_config(vcs_handler.acl_repo_name)
# maybe damaged/non existent settings. We still want to
# pass that point to validate on is_valid_and_existing_repo
# and return proper HTTP Code back to client
if vcs_conf:
vcs_handler.repo_vcs_config = vcs_conf
# check for type, presence in database and on filesystem
if not vcs_handler.is_valid_and_existing_repo(
vcs_handler.acl_repo_name,
@ -218,10 +230,6 @@ class VCSMiddleware(object):
environ['REPO_NAME'] = vcs_handler.url_repo_name
# register repo config back to the handler
vcs_handler.repo_vcs_config = self.vcs_config(
vcs_handler.acl_repo_name)
# Wrap handler in middlewares if they are enabled.
vcs_handler = self.wrap_in_gzip_if_enabled(
vcs_handler, self.config)