def __before__(self, action, **params): c.__timer = time.time() app_globals.app_globals._check_uptodate() identify_user() i18n.handle_request(request, c)
def __call__(self, environ, start_response): # we need to intercept and fix the api version # as it will have a "/" at the start routes_dict = environ['pylons.routes_dict'] api_version = routes_dict.get('ver') if api_version: api_version = api_version[1:] routes_dict['ver'] = int(api_version) identify_user() try: context = {'model': model, 'user': c.user, 'auth_user_obj': c.userobj} logic.check_access('site_read', context) except NotAuthorized: response_msg = self._finish(403, _('Not authorized to see this page')) # Call start_response manually instead of the parent __call__ # because we want to end the request instead of continuing. response_msg = response_msg.encode('utf8') body = '%i %s' % (response.status_int, response_msg) start_response(body, response.headers.items()) return [response_msg] # avoid status_code_redirect intercepting error responses environ['pylons.status_code_redirect'] = True return base.BaseController.__call__(self, environ, start_response)
def __call__(self, environ, start_response): # we need to intercept and fix the api version # as it will have a "/" at the start routes_dict = environ['pylons.routes_dict'] api_version = routes_dict.get('ver') if api_version: api_version = api_version[1:] routes_dict['ver'] = int(api_version) identify_user() try: context = { 'model': model, 'user': c.user, 'auth_user_obj': c.userobj } logic.check_access('site_read', context) except NotAuthorized: response_msg = self._finish(403, _('Not authorized to see this page')) # Call start_response manually instead of the parent __call__ # because we want to end the request instead of continuing. response_msg = response_msg.encode('utf8') body = '%i %s' % (response.status_int, response_msg) start_response(body, response.headers.items()) return [response_msg] # avoid status_code_redirect intercepting error responses environ['pylons.status_code_redirect'] = True return base.BaseController.__call__(self, environ, start_response)
def ckan_before_request(): u'''Common handler executed before all Flask requests''' # Update app_globals app_globals.app_globals._check_uptodate() # Identify the user from the repoze cookie or the API header # Sets g.user and g.userobj identify_user()
def ckan_before_request(): u'''Common handler executed before all Flask requests''' # Update app_globals app_globals.app_globals._check_uptodate() # Identify the user from the repoze cookie or the API header # Sets g.user and g.userobj identify_user() # Provide g.controller and g.action for backward compatibility # with extensions set_controller_and_action()
def ckan_before_request(): u''' Common handler executed before all Flask requests If a response is returned by any of the functions called ( currently ``identify_user()` only) any further processing of the request will be stopped and that response will be returned. ''' response = None # Update app_globals app_globals.app_globals._check_uptodate() # Identify the user from the repoze cookie or the API header # Sets g.user and g.userobj response = identify_user() # Provide g.controller and g.action for backward compatibility # with extensions set_controller_and_action() set_ckan_current_url(request.environ) g.__timer = time.time() return response
def ckan_before_request() -> Optional[Response]: u''' Common handler executed before all Flask requests If a response is returned by any of the functions called ( currently ``identify_user()` only) any further processing of the request will be stopped and that response will be returned. ''' response = None g.__timer = time.time() # Update app_globals app_globals.app_globals._check_uptodate() # This is needed for the TESTS of the CKAN extensions only! # we should remove it as soon as the maintainers of the # CKAN extensions change their tests according to the new changes. if config.get_value("testing"): set_remote_user_as_current_user_for_tests() # Identify the user from the flask-login cookie or the API header # Sets g.user and g.userobj for extensions response = identify_user() # Provide g.controller and g.action for backward compatibility # with extensions set_controller_and_action() set_ckan_current_url(request.environ) return response