##// END OF EJS Templates
code: added more logging, and some notes
marcink -
r1300:0ec329be default
parent child Browse files
Show More
@@ -132,7 +132,7 b' def exception_view(exc, request):'
132 log.debug('json-rpc error rpc_id:%s "%s"', rpc_id, fault_message)
132 log.debug('json-rpc error rpc_id:%s "%s"', rpc_id, fault_message)
133 elif isinstance(exc, JSONRPCValidationError):
133 elif isinstance(exc, JSONRPCValidationError):
134 colander_exc = exc.colander_exception
134 colander_exc = exc.colander_exception
135 #TODO: think maybe of nicer way to serialize errors ?
135 # TODO(marcink): think maybe of nicer way to serialize errors ?
136 fault_message = colander_exc.asdict()
136 fault_message = colander_exc.asdict()
137 log.debug('json-rpc error rpc_id:%s "%s"', rpc_id, fault_message)
137 log.debug('json-rpc error rpc_id:%s "%s"', rpc_id, fault_message)
138 elif isinstance(exc, JSONRPCForbidden):
138 elif isinstance(exc, JSONRPCForbidden):
@@ -240,7 +240,7 b' def request_view(request):'
240 message=('Missing non optional `%s` arg in JSON DATA' % arg)
240 message=('Missing non optional `%s` arg in JSON DATA' % arg)
241 )
241 )
242
242
243 # sanitze extra passed arguments
243 # sanitize extra passed arguments
244 for k in request.rpc_params.keys()[:]:
244 for k in request.rpc_params.keys()[:]:
245 if k not in func_kwargs:
245 if k not in func_kwargs:
246 del request.rpc_params[k]
246 del request.rpc_params[k]
@@ -269,9 +269,10 b' def setup_request(request):'
269 We need to raise JSONRPCError here if we want to return some errors back to
269 We need to raise JSONRPCError here if we want to return some errors back to
270 user.
270 user.
271 """
271 """
272
272 log.debug('Executing setup request: %r', request)
273 log.debug('Executing setup request: %r', request)
273 request.rpc_ip_addr = get_ip_addr(request.environ)
274 request.rpc_ip_addr = get_ip_addr(request.environ)
274 # TODO: marcink, deprecate GET at some point
275 # TODO(marcink): deprecate GET at some point
275 if request.method not in ['POST', 'GET']:
276 if request.method not in ['POST', 'GET']:
276 log.debug('unsupported request method "%s"', request.method)
277 log.debug('unsupported request method "%s"', request.method)
277 raise JSONRPCError(
278 raise JSONRPCError(
@@ -308,6 +309,8 b' def setup_request(request):'
308 if not api_key:
309 if not api_key:
309 raise KeyError('api_key or auth_token')
310 raise KeyError('api_key or auth_token')
310
311
312 # TODO(marcink): support passing in token in request header
313
311 request.rpc_api_key = api_key
314 request.rpc_api_key = api_key
312 request.rpc_id = json_body['id']
315 request.rpc_id = json_body['id']
313 request.rpc_method = json_body['method']
316 request.rpc_method = json_body['method']
@@ -485,8 +488,7 b' def includeme(config):'
485 config.registry.jsonrpc_methods = OrderedDict()
488 config.registry.jsonrpc_methods = OrderedDict()
486
489
487 # match filter by given method only
490 # match filter by given method only
488 config.add_view_predicate(
491 config.add_view_predicate('jsonrpc_method', MethodPredicate)
489 'jsonrpc_method', MethodPredicate)
490
492
491 config.add_renderer(DEFAULT_RENDERER, ExtJsonRenderer(
493 config.add_renderer(DEFAULT_RENDERER, ExtJsonRenderer(
492 serializer=json.dumps, indent=4))
494 serializer=json.dumps, indent=4))
@@ -846,7 +846,7 b' class AuthUser(object):'
846 Fills in user data and propagates values to this instance. Maps fetched
846 Fills in user data and propagates values to this instance. Maps fetched
847 user attributes to this class instance attributes
847 user attributes to this class instance attributes
848 """
848 """
849
849 log.debug('starting data propagation for new potential AuthUser')
850 user_model = UserModel()
850 user_model = UserModel()
851 anon_user = self.anonymous_user = User.get_default_user(cache=True)
851 anon_user = self.anonymous_user = User.get_default_user(cache=True)
852 is_user_loaded = False
852 is_user_loaded = False
@@ -393,7 +393,8 b' def get_auth_user(environ):'
393 request.GET.get('api_key', ''))
393 request.GET.get('api_key', ''))
394
394
395 if _auth_token:
395 if _auth_token:
396 # when using API_KEY we are sure user exists.
396 # when using API_KEY we assume user exists, and
397 # doesn't need auth based on cookies.
397 auth_user = AuthUser(api_key=_auth_token, ip_addr=ip_addr)
398 auth_user = AuthUser(api_key=_auth_token, ip_addr=ip_addr)
398 authenticated = False
399 authenticated = False
399 else:
400 else:
@@ -412,8 +413,7 b' def get_auth_user(environ):'
412
413
413 if password_changed(auth_user, session):
414 if password_changed(auth_user, session):
414 session.invalidate()
415 session.invalidate()
415 cookie_store = CookieStoreWrapper(
416 cookie_store = CookieStoreWrapper(session.get('rhodecode_user'))
416 session.get('rhodecode_user'))
417 auth_user = AuthUser(ip_addr=ip_addr)
417 auth_user = AuthUser(ip_addr=ip_addr)
418
418
419 authenticated = cookie_store.get('is_authenticated')
419 authenticated = cookie_store.get('is_authenticated')
@@ -52,9 +52,11 b' def pylons_compatibility_tween_factory(h'
52 request.environ, request.registry.settings.get('vcs.backends'))
52 request.environ, request.registry.settings.get('vcs.backends'))
53
53
54 if vcs_handler:
54 if vcs_handler:
55 # save detected VCS type for later re-use
55 request.environ[VCS_TYPE_KEY] = vcs_handler.SCM
56 request.environ[VCS_TYPE_KEY] = vcs_handler.SCM
56 return handler(request)
57 return handler(request)
57
58
59 # mark that we didn't detect an VCS, and we can skip detection later on
58 request.environ[VCS_TYPE_KEY] = VCS_TYPE_SKIP
60 request.environ[VCS_TYPE_KEY] = VCS_TYPE_SKIP
59
61
60 # Setup pylons globals.
62 # Setup pylons globals.
General Comments 0
You need to be logged in to leave comments. Login now