예제 #1
0
def module_handler(request):
    """
    Handle module request from UI. Response from this request builds
    UI Explorer tree
    """
    logging.debug("module_handler: enter")
    lst = []
    if request.user.is_authenticated():
        path = request.GET.get('node', '')

        username = request.user.username
        if path == 'root':
            # Request for root models
            modules = ModuleAdmin.get_modulelist(username)
            modules.sort()
            path = ''
        else:
            modules = [path.split('/')[0]]

        for module in modules:
            filename = ModuleAdmin.cxml_path(username, module)
            if filename is not None:
                logging.debug("module_handler: loading " + filename)
                module = Cxml(filename)
                nodes = module.get_lazy_node(path)
                lst.extend([ET.tostring(node) for node in nodes])
            else:
                logging.error("module_handler: %s not found !!" + module)

    logging.debug("module_handler: exit")
    return render_to_response('loader.xml', {'nodes': lst}, RequestContext(request))
예제 #2
0
def module_handler(request):
    '''
    Handle module request from UI. Response from this request builds
    UI Explorer tree
    '''
    logging.debug("module_handler: enter")
    lst = []
    if request.user.is_authenticated():
        modules = []
        path = request.GET.get('node', '')

        username = request.user.username
        if path == 'root':
             # Request for root models
            modules = ModuleAdmin.get_modulelist(username)
            modules.sort()
            path = ''
        else:
            modules = [path.split('/')[0]]

        for module in modules:
            filename = ModuleAdmin.cxml_path(username, module)
            if filename is not None:
                logging.debug("module_handler: loading " + filename)
                module = Cxml(filename)
                nodes = module.get_lazy_node(path)
                lst.extend([ET.tostring(node) for node in nodes])
            else:
                logging.error("module_handler: %s not found !!" + module)

    logging.debug("module_handler: exit")
    return render_to_response('loader.xml', {'nodes': lst}, RequestContext(request))
예제 #3
0
def module_handler(request):
    '''
    Handle module request from UI. Response from this request builds
    UI Explorer tree
    '''
    lst = []
    if request.user.is_authenticated():
        modules = []
        path = request.GET.get('node', '')

        if path == 'root':
             # Request for root models
            uid = request.user.id
            userprofile = UserProfile.objects.filter(user=uid)
            if len(userprofile) > 0:
                modules = [e.module.strip() for e in userprofile.all()]
            modules.sort()
            path = ''
        else:
            modules = [(path.split('/'))[0]]

        for module in modules:
            filename = os.path.join('data', 'users', request.user.username,
                                    'cxml', module + '.xml')
            module = Cxml(filename)
            nodes = module.get_lazy_node(path)
            lst.extend([ET.tostring(node) for node in nodes])
    return render_to_response('loader.xml', {'nodes': lst}, RequestContext(request))