コード例 #1
0
ファイル: base.py プロジェクト: berlinonline/ckan
    def __before__(self, action, **params):
        c.__timer = time.time()
        app_globals.app_globals._check_uptodate()

        identify_user()

        i18n.handle_request(request, c)
コード例 #2
0
ファイル: api.py プロジェクト: berlinonline/ckan
    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)
コード例 #3
0
    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)
コード例 #4
0
ファイル: base.py プロジェクト: mattcen/ckan
    def __before__(self, action, **params):
        c.__timer = time.time()
        app_globals.app_globals._check_uptodate()

        identify_user()

        i18n.handle_request(request, c)
コード例 #5
0
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()
コード例 #6
0
ファイル: flask_app.py プロジェクト: HighwayThree/ckan
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()
コード例 #7
0
ファイル: flask_app.py プロジェクト: sopanawit/ckan
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()
コード例 #8
0
ファイル: flask_app.py プロジェクト: mattbis/ckan
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()
コード例 #9
0
ファイル: flask_app.py プロジェクト: dice-group/dice-ckan
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
コード例 #10
0
ファイル: flask_app.py プロジェクト: tino097/ckan
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