##// END OF EJS Templates
exceptions: removed unused traceback formatting.
marcink -
r489:0ece6502 default
parent child Browse files
Show More
@@ -1,93 +1,91 b''
1 1 # RhodeCode VCSServer provides access to different vcs backends via network.
2 2 # Copyright (C) 2014-2018 RhodeCode GmbH
3 3 #
4 4 # This program is free software; you can redistribute it and/or modify
5 5 # it under the terms of the GNU General Public License as published by
6 6 # the Free Software Foundation; either version 3 of the License, or
7 7 # (at your option) any later version.
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 General Public License
15 15 # along with this program; if not, write to the Free Software Foundation,
16 16 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 17
18 18 import sys
19 19 import traceback
20 20 import logging
21 21 import urlparse
22 22
23 23 from vcsserver.lib.rc_cache import region_meta
24 24 log = logging.getLogger(__name__)
25 25
26 26
27 27 class RepoFactory(object):
28 28 """
29 29 Utility to create instances of repository
30 30
31 31 It provides internal caching of the `repo` object based on
32 32 the :term:`call context`.
33 33 """
34 34 repo_type = None
35 35
36 36 def __init__(self):
37 37 self._cache_region = region_meta.dogpile_cache_regions['repo_object']
38 38
39 39 def _create_config(self, path, config):
40 40 config = {}
41 41 return config
42 42
43 43 def _create_repo(self, wire, create):
44 44 raise NotImplementedError()
45 45
46 46 def repo(self, wire, create=False):
47 47 """
48 48 Get a repository instance for the given path.
49 49
50 50 Uses internally the low level beaker API since the decorators introduce
51 51 significant overhead.
52 52 """
53 53 region = self._cache_region
54 54 context = wire.get('context', None)
55 55 repo_path = wire.get('path', '')
56 56 context_uid = '{}'.format(context)
57 57 cache = wire.get('cache', True)
58 58 cache_on = context and cache
59 59
60 60 @region.conditional_cache_on_arguments(condition=cache_on)
61 61 def create_new_repo(_repo_type, _repo_path, _context_uid):
62 62 return self._create_repo(wire, create)
63 63
64 64 repo = create_new_repo(self.repo_type, repo_path, context_uid)
65 65 return repo
66 66
67 67
68 68 def obfuscate_qs(query_string):
69 69 if query_string is None:
70 70 return None
71 71
72 72 parsed = []
73 73 for k, v in urlparse.parse_qsl(query_string, keep_blank_values=True):
74 74 if k in ['auth_token', 'api_key']:
75 75 v = "*****"
76 76 parsed.append((k, v))
77 77
78 78 return '&'.join('{}{}'.format(
79 79 k, '={}'.format(v) if v else '') for k, v in parsed)
80 80
81 81
82 82 def raise_from_original(new_type):
83 83 """
84 84 Raise a new exception type with original args and traceback.
85 85 """
86 86 exc_type, exc_value, exc_traceback = sys.exc_info()
87 87
88 traceback.format_exception(exc_type, exc_value, exc_traceback)
89
90 88 try:
91 89 raise new_type(*exc_value.args), None, exc_traceback
92 90 finally:
93 91 del exc_traceback
General Comments 0
You need to be logged in to leave comments. Login now