Exemplo n.º 1
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)
Exemplo n.º 2
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)
Exemplo 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)
Exemplo 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)
Exemplo 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)
Exemplo n.º 6
0
Arquivo: testing.py Projeto: 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)
Exemplo n.º 7
0
Arquivo: testing.py Projeto: 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
Exemplo 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
Exemplo 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
Exemplo 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
Exemplo 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
Exemplo 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
Exemplo 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
Exemplo n.º 14
0
import re

from .primitives import Id, Type, DisplayText
from .osid.osid_errors import AlreadyExists, NotFound

from dlkit.runtime import PROXY_SESSION
from dlkit.runtime.managers import Runtime

CONDITION = PROXY_SESSION.get_proxy_condition()
PROXY = PROXY_SESSION.get_proxy(CONDITION)

LM = Runtime().get_service_manager('LEARNING',
                                   implementation='TEST_SERVICE_HANDCAR')
# not sure why Repository requires proxy...
RM = Runtime().get_service_manager('REPOSITORY',
                                   proxy=PROXY,
                                   implementation='TEST_SERVICE_HANDCAR')

SANDBOX_TYPE = Type({
    'id': 'mc3-objectivebank%3Amc3.learning.objectivebank.sandbox%40MIT-OEIT',
    'authority': 'MIT-OEIT',
    'identifierNamespace': 'mc3-objectivebank',
    'identifier': 'mc3.learning.objectivebank.sandbox',
    'domain': '',
    'displayName': '',
    'description': '',
    'displayLabel': ''})


class BankHierarchyUrls(object):
    """