##// END OF EJS Templates
core: handle edge case requesting matched routes but with hg/svn/git or api context....
marcink -
r3076:86f6e7c0 default
parent child Browse files
Show More
@@ -22,7 +22,7 b' import time'
22 22 import logging
23 23 import operator
24 24
25 from pyramid.httpexceptions import HTTPFound, HTTPForbidden
25 from pyramid.httpexceptions import HTTPFound, HTTPForbidden, HTTPBadRequest
26 26
27 27 from rhodecode.lib import helpers as h, diffs
28 28 from rhodecode.lib.utils2 import StrictAttributeDict, safe_int, datetime_to_time
@@ -100,6 +100,13 b' class BaseAppView(object):'
100 100 self.request = request
101 101 self.context = context
102 102 self.session = request.session
103 if not hasattr(request, 'user'):
104 # NOTE(marcink): edge case, we ended up in matched route
105 # but probably of web-app context, e.g API CALL/VCS CALL
106 if hasattr(request, 'vcs_call') or hasattr(request, 'rpc_method'):
107 log.warning('Unable to process request `%s` in this scope', request)
108 raise HTTPBadRequest()
109
103 110 self._rhodecode_user = request.user # auth user
104 111 self._rhodecode_db_user = self._rhodecode_user.get_instance()
105 112 self._maybe_needs_password_change(
@@ -20,6 +20,23 b''
20 20 from rhodecode.config import routing_links
21 21
22 22
23 class VCSCallPredicate(object):
24 def __init__(self, val, config):
25 self.val = val
26
27 def text(self):
28 return 'vcs_call route = %s' % self.val
29
30 phash = text
31
32 def __call__(self, info, request):
33 if hasattr(request, 'vcs_call'):
34 # skip vcs calls
35 return False
36
37 return True
38
39
23 40 def includeme(config):
24 41
25 42 config.add_route(
@@ -51,3 +68,6 b' def includeme(config):'
51 68
52 69 # Scan module for configuration decorators.
53 70 config.scan('.views', ignore='.tests')
71
72 config.add_route_predicate(
73 'skip_vcs_call', VCSCallPredicate)
General Comments 0
You need to be logged in to leave comments. Login now