##// END OF EJS Templates
Added tag v4.13.1 for changeset c3ded3ff17e9
Added tag v4.13.1 for changeset c3ded3ff17e9

File last commit:

r489:0ece6502 default
r518:c2efa29d stable
Show More
base.py
91 lines | 2.8 KiB | text/x-python | PythonLexer
initial commit
r0 # RhodeCode VCSServer provides access to different vcs backends via network.
core: udpate copyright string to 2018
r352 # Copyright (C) 2014-2018 RhodeCode GmbH
initial commit
r0 #
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
exception-handling: better handling of remote exception and logging....
r171 import sys
import traceback
initial commit
r0 import logging
remote-clone: obfuscate also given query string paramas that RhodeCode uses. Fixes #4668
r106 import urlparse
initial commit
r0
caches: replaced beaker with dogpile cache.
r483 from vcsserver.lib.rc_cache import region_meta
initial commit
r0 log = logging.getLogger(__name__)
class RepoFactory(object):
"""
Utility to create instances of repository
It provides internal caching of the `repo` object based on
the :term:`call context`.
"""
caches: replaced beaker with dogpile cache.
r483 repo_type = None
initial commit
r0
caches: replaced beaker with dogpile cache.
r483 def __init__(self):
self._cache_region = region_meta.dogpile_cache_regions['repo_object']
initial commit
r0
def _create_config(self, path, config):
config = {}
return config
def _create_repo(self, wire, create):
raise NotImplementedError()
def repo(self, wire, create=False):
"""
Get a repository instance for the given path.
Uses internally the low level beaker API since the decorators introduce
significant overhead.
"""
caches: replaced beaker with dogpile cache.
r483 region = self._cache_region
context = wire.get('context', None)
repo_path = wire.get('path', '')
context_uid = '{}'.format(context)
cache = wire.get('cache', True)
cache_on = context and cache
@region.conditional_cache_on_arguments(condition=cache_on)
def create_new_repo(_repo_type, _repo_path, _context_uid):
initial commit
r0 return self._create_repo(wire, create)
caches: replaced beaker with dogpile cache.
r483 repo = create_new_repo(self.repo_type, repo_path, context_uid)
return repo
remote-clone: obfuscate also given query string paramas that RhodeCode uses. Fixes #4668
r106
def obfuscate_qs(query_string):
parse_qs: improved parsing of query string for obfuscation.
r107 if query_string is None:
return None
remote-clone: obfuscate also given query string paramas that RhodeCode uses. Fixes #4668
r106 parsed = []
parse_qs: improved parsing of query string for obfuscation.
r107 for k, v in urlparse.parse_qsl(query_string, keep_blank_values=True):
remote-clone: obfuscate also given query string paramas that RhodeCode uses. Fixes #4668
r106 if k in ['auth_token', 'api_key']:
v = "*****"
parsed.append((k, v))
parse_qs: improved parsing of query string for obfuscation.
r107 return '&'.join('{}{}'.format(
k, '={}'.format(v) if v else '') for k, v in parsed)
exception-handling: better handling of remote exception and logging....
r171
def raise_from_original(new_type):
"""
Raise a new exception type with original args and traceback.
"""
exc_type, exc_value, exc_traceback = sys.exc_info()
try:
raise new_type(*exc_value.args), None, exc_traceback
finally:
del exc_traceback