Esempio n. 1
0
def get_repository_manager():
    request = SimpleRequest(username='******')
    condition = PROXY_SESSION.get_proxy_condition()
    condition.set_http_request(request)
    proxy = PROXY_SESSION.get_proxy(condition)
    return RUNTIME.get_service_manager(
        'REPOSITORY', implementation='TEST_SERVICE_FILESYSTEM', proxy=proxy)
Esempio n. 2
0
def get_repository_manager():
    condition = PROXY_SESSION.get_proxy_condition()
    dummy_request = SimpleRequest(username=web.ctx.env.get(
        'HTTP_X_API_PROXY', '*****@*****.**'),
                                  authenticated=True)
    condition.set_http_request(dummy_request)

    if 'HTTP_X_API_LOCALE' in web.ctx.env:
        language_code = web.ctx.env['HTTP_X_API_LOCALE'].lower()
        if language_code in ['en', 'hi', 'te']:
            if language_code == 'en':
                language_code = 'ENG'
                script_code = 'LATN'
            elif language_code == 'hi':
                language_code = 'HIN'
                script_code = 'DEVA'
            else:
                language_code = 'TEL'
                script_code = 'TELU'
        else:
            language_code = DEFAULT_LANGUAGE_TYPE.identifier
            script_code = DEFAULT_SCRIPT_TYPE.identifier

        locale = InitializableLocale(language_type_identifier=language_code,
                                     script_type_identifier=script_code)

        condition.set_locale(locale)

    proxy = PROXY_SESSION.get_proxy(condition)
    return RUNTIME.get_service_manager('REPOSITORY', proxy=proxy)
Esempio n. 3
0
 def _get_aws_manager(self, manager_type):
     condition = PROXY_SESSION.get_proxy_condition()
     condition.set_http_request(self.req)
     proxy = PROXY_SESSION.get_proxy(condition)
     return RUNTIME.get_service_manager(manager_type.upper(),
                                        implementation='TEST_SERVICE_AWS',
                                        proxy=proxy)
Esempio n. 4
0
def get_assessment_manager():
    request = SimpleRequest(username='******')
    condition = PROXY_SESSION.get_proxy_condition()
    condition.set_http_request(request)
    proxy = PROXY_SESSION.get_proxy(condition)
    return RUNTIME.get_service_manager(
        'ASSESSMENT', implementation='TEST_SERVICE_FILESYSTEM', proxy=proxy)
Esempio n. 5
0
def get_logging_manager():
    condition = PROXY_SESSION.get_proxy_condition()
    dummy_request = SimpleRequest(username=web.ctx.env.get(
        'HTTP_X_API_PROXY', '*****@*****.**'),
                                  authenticated=True)
    condition.set_http_request(dummy_request)
    proxy = PROXY_SESSION.get_proxy(condition)
    return RUNTIME.get_service_manager('LOGGING', proxy=proxy)
Esempio n. 6
0
File: testing.py Progetto: UOC/dlkit
def get_manager(request, manager_type):
    condition = PROXY_SESSION.get_proxy_condition()
    condition.set_http_request(request)
    proxy = PROXY_SESSION.get_proxy(condition)
    return RUNTIME.get_service_manager(
        manager_type.upper(),
        implementation='TEST_SERVICE_FUNCTIONAL',
        proxy=proxy)
Esempio n. 7
0
File: testing.py Progetto: UOC/dlkit
def get_agent_id(agent_id):
    """Not a great hack...depends too much on internal DLKit knowledge"""
    if '@mit.edu' not in agent_id:
        agent_id += '@mit.edu'
    test_request = SimpleRequest(agent_id)
    condition = PROXY_SESSION.get_proxy_condition()
    condition.set_http_request(test_request)
    proxy = PROXY_SESSION.get_proxy(condition)
    resm = RUNTIME.get_service_manager(
        'RESOURCE', implementation='TEST_SERVICE_FUNCTIONAL', proxy=proxy)
    return resm.effective_agent_id
Esempio n. 8
0
def activate_managers(request):
    """
    Create an initial grading manager and store it in the user session
    """
    if 'gm' not in request.session:
        condition = PROXY_SESSION.get_proxy_condition()
        condition.set_http_request(request)
        proxy = PROXY_SESSION.get_proxy(condition)
        set_session_data(request, 'gm',
                         RUNTIME.get_service_manager('GRADING', proxy=proxy))

    return request
Esempio n. 9
0
def activate_managers(request):
    """
    Create an initial assessment manager and store it in the user session
    """
    if 'rm' not in request.session:
        condition = PROXY_SESSION.get_proxy_condition()
        condition.set_http_request(request)
        proxy = PROXY_SESSION.get_proxy(condition)
        set_session_data(
            request, 'rm',
            RUNTIME.get_service_manager('REPOSITORY', proxy=proxy))

    return request
Esempio n. 10
0
def get_managers(username='******'):
    managers = [('am', 'ASSESSMENT'), ('authzm', 'AUTHORIZATION'),
                ('logm', 'LOGGING'), ('rm', 'REPOSITORY')]
    results = {}
    for manager in managers:
        nickname = manager[0]
        service_name = manager[1]
        condition = PROXY_SESSION.get_proxy_condition()
        dummy_request = SimpleRequest(username=username, authenticated=True)
        condition.set_http_request(dummy_request)
        proxy = PROXY_SESSION.get_proxy(condition)
        results[nickname] = RUNTIME.get_service_manager(service_name,
                                                        proxy=proxy)

    return results
Esempio n. 11
0
def activate_managers(request):
    """
    Create initial managers and store them in the user session
    """
    managers = [
        ('authzm', 'AUTHORIZATION'),
    ]

    for manager in managers:
        nickname = manager[0]
        service_name = manager[1]
        if nickname not in request.session:
            condition = PROXY_SESSION.get_proxy_condition()
            condition.set_http_request(request)
            proxy = PROXY_SESSION.get_proxy(condition)
            set_session_data(
                request, nickname,
                RUNTIME.get_service_manager(service_name, proxy=proxy))
    return request
Esempio n. 12
0
def get_object_bank_from_request(request):
    """parse out the right params before passing to get_object_bank
    Do NOT use the convenience methods here with session, etc."""
    valid_params = ['/assessment/items/']
    path = request.path
    if any(p in path for p in valid_params):
        test_request = SimpleRequest(username=request.user.username)
        condition = PROXY_SESSION.get_proxy_condition()
        condition.set_http_request(test_request)
        proxy = PROXY_SESSION.get_proxy(condition)
        am = RUNTIME.get_service_manager('ASSESSMENT', proxy=proxy)
        try:
            if '/items/' in path:
                object_id = path.split('/items/')[-1]
                return get_object_bank(am, object_id, object_type='item')
        except NotFound:
            return None
    else:
        return None
Esempio n. 13
0
def activate_managers(request):
    """
    Create initial managers and store them in the user session
    """
    managers = [('am', 'ASSESSMENT'),
        ('cm', 'COMMENTING'),
        ('gm', 'GRADING'),
        ('lm', 'LEARNING'),
        ('rm', 'REPOSITORY')]

    for manager in managers:
        nickname = manager[0]
        service_name = manager[1]
        if nickname not in request.session:
            condition = PROXY_SESSION.get_proxy_condition()
            condition.set_http_request(request)
            proxy = PROXY_SESSION.get_proxy(condition)
            set_session_data(request, nickname, RUNTIME.get_service_manager(service_name,
                                                                            proxy=proxy))
    return request