Пример #1
0
def project_graph(request):
    if request.is_ajax():
        boxList = request.GET.get("list")
        # Project Id(or Name) should be stored in SESSION
        projectName = request.session["projectName"]
        # projectName = request.GET.get('projectName')
        project = loadProject(request)

        provider = ProjectRunsTreeProvider(project)

        g = project.getRunsGraph()
        root = g.getRoot()
        root.w = 100
        root.h = 40
        root.item = WebNode("project", x=0, y=0)

        # Assign the width and height
        for box in boxList.split(","):
            id, w, h = box.split("-")
            node = g.getNode(id)
            if node is None:
                print "Get NONE node: i=%s" % id
            else:
                node.id = id
                node.w = float(w)
                node.h = float(h)

        lt = gg.LevelTree(g)
        lt.paint(createNode, createEdge)
        nodeList = []

        for node in g.getNodes():
            try:
                hx = node.w / 2
                hy = node.h / 2
                childs = [c.getName() for c in node.getChilds()]
                status, color = getNodeStateColor(node)

                info = ""
                if str(node.id) != "PROJECT":
                    protocol = project.getProtocol(int(node.id))
                    info = provider.getObjectInfo(protocol)["values"][0]

                nodeList.append(
                    {
                        "id": node.getName(),
                        "x": node.item.x - hx,
                        "y": node.item.y - hy,
                        "color": color,
                        "status": info,
                        "childs": childs,
                    }
                )
            except Exception:
                print "Error with node: ", node.getName()
                raise

        #        print nodeList
        jsonStr = json.dumps(nodeList, ensure_ascii=False)
        return HttpResponse(jsonStr, mimetype="application/javascript")
Пример #2
0
def tree_prot_view(request):
    projectName = request.session['projectName'] 
    project = loadProject(request)
     
    # load the protocol tree current active
    htmlTree = loadProtTree(project)
    
    return render_to_response('project_content/tree_prot_view.html', {'protTreeHtml': htmlTree})
Пример #3
0
def tree_prot_view(request):
    project = loadProject(request)

    # load the protocol tree current active
    htmlTree = loadProtTree(project)

    return render_to_response('project_content/tree_prot_view.html',
                              {'protTreeHtml': htmlTree})
Пример #4
0
def project_graph(request):
    if request.is_ajax():
        boxList = request.GET.get('list')
        # Project Id(or Name) should be stored in SESSION
        projectName = request.session['projectName']
        # projectName = request.GET.get('projectName')
        project = loadProject(request)

        provider = ProjectRunsTreeProvider(project)

        g = project.getRunsGraph()
        root = g.getRoot()
        root.w = 100
        root.h = 40
        root.item = WebNode('project', x=0, y=0)

        # Assign the width and height
        for box in boxList.split(','):
            id, w, h = box.split('-')
            node = g.getNode(id)
            if node is None:
                print "Get NONE node: i=%s" % id
            else:
                node.id = id
                node.w = float(w)
                node.h = float(h)

        lt = gg.LevelTree(g)
        lt.paint(createNode, createEdge)
        nodeList = []

        for node in g.getNodes():
            try:
                hx = node.w / 2
                hy = node.h / 2
                childs = [c.getName() for c in node.getChilds()]
                status, color = getNodeStateColor(node)

                info = ""
                if str(node.id) != "PROJECT":
                    protocol = project.getProtocol(int(node.id))
                    info = provider.getObjectInfo(protocol)["values"][0]

                nodeList.append({
                    'id': node.getName(),
                    'x': node.item.x - hx,
                    'y': node.item.y - hy,
                    'color': color,
                    'status': info,
                    'childs': childs
                })
            except Exception:
                print "Error with node: ", node.getName()
                raise

#        print nodeList
        jsonStr = json.dumps(nodeList, ensure_ascii=False)
        return HttpResponse(jsonStr, mimetype='application/javascript')
Пример #5
0
def stop_protocol(request):
    if request.is_ajax():
        project = loadProject(request)
        protId = request.GET.get('protocolId', None)
        protocol = project.getProtocol(int(protId))
     
        project.stopProtocol(protocol)
        
    return HttpResponse(content_type='application/javascript')
Пример #6
0
def update_graph_view(request):
    status = request.GET.get('status', None)
    project = loadProject(request)
    project_settings = project.getSettings()

    project_settings.runsView.set(int(status))

    project_settings.write()
    return HttpResponse(content_type='application/javascript')
Пример #7
0
def run_table_graph(request):
    from pyworkflow.gui.tree import ProjectRunsTreeProvider

    try:
        projectName = request.session['projectName']
        project = loadProject(request)
        project_settings = project.getSettings()
        provider = ProjectRunsTreeProvider(project)

        runs = request.session['runs']
        runsNew = formatProvider(provider, "runs")

        refresh = False
        listNewElm = []

        if len(runs) != len(runsNew):
            print 'Change detected, different size'
            refresh = True
        else:
            for kx, vx in runs:
                for ky, vy in runsNew:
                    if kx == ky and vx != vy:
                        print 'Change detected', vx, vy
                        #                   refresh = True
                        listNewElm.append(vy)
        if refresh:
            request.session['runs'] = runsNew

            # Get the selected runs stored in BD
            selectedRuns = project_settings.runSelection

            # Get the run mode view (0:list / 1:graph / 2:small graph) stored in BD
            runsView = project_settings.runsView.get()

            context = {
                'runs': runsNew,
                'columns': provider.getColumns(),
                'runsView': runsView,
                'selectedRuns': selectedRuns
            }

            return render_to_response('project_content/run_table_graph.html',
                                      context)

        elif listNewElm:
            request.session['runs'] = runsNew
            jsonStr = json.dumps(listNewElm, ensure_ascii=False)
            return HttpResponse(jsonStr, mimetype='application/json')

        else:
            print "No changes detected"
            return HttpResponse("ok", mimetype='text/plain')

    except Exception:
        print "Stopped script"
        return HttpResponse("stop", mimetype='text/plain')
Пример #8
0
def stop_protocol(request):
    if request.is_ajax():
        projectName = request.session["projectName"]
        project = loadProject(request)
        protId = request.GET.get("protocolId", None)
        protocol = project.getProtocol(int(protId))

        project.stopProtocol(protocol)

    return HttpResponse(mimetype="application/javascript")
Пример #9
0
def update_graph_view(request):
    status = request.GET.get('status', None)
    projectName = request.session['projectName']
    project = loadProject(request)
    project_settings = project.getSettings()

    project_settings.runsView.set(int(status))
    
    project_settings.write()
    return HttpResponse(mimetype='application/javascript')
Пример #10
0
def elements_graph(request):
    if request.is_ajax():
        project = loadProject(request)
        g = project.getSourceGraph()

        elmList = []
        for node in g.getNodes():
            elmList.append({'id': node.getName(), 'label': node.getLabel()})

        jsonStr = json.dumps(elmList, ensure_ascii=False)
        return HttpResponse(jsonStr, content_type='application/javascript')
Пример #11
0
def protocol_info(request):
    from pyworkflow.web.app.views_util import parseText
    from pyworkflow.em.data import EMObject  
    
    if request.is_ajax():
        jsonStr = ''
#         projectName = request.session['projectName']
        protId = request.GET.get('protocolId', None)
        
#         projectPath = request.session['projectPath']
        project = loadProject(request)
        
        if len(protId) > 0: 
            protocol = project.getProtocol(int(protId))
            
            # PROTOCOL IO
            input_obj = [{'name':name, 
                          'nameId': attr.getNameId(), 
                          'id': attr.getObjId(), 
                          'info': str(attr.get()) if attr.isPointer() else str(attr)} 
                         for name, attr in protocol.iterInputAttributes()]
            
            output_obj = [{'name':name, 
                           'nameId': attr.getNameId(), 
                           'id': attr.getObjId(), 
                           'info': str(attr)} 
                          for name, attr in protocol.iterOutputAttributes(EMObject)]
    
            # PROTOCOL SUMMARY
            summary = parseText(protocol.summary())
            
            # PROTOCOL METHODS
            methods = parseText(protocol.methods())
    
            # STATUS
            status = protocol.status.get()
            
            # LOGS (ERROR & OUTPUT)
            fOutString, fErrString, fScpnString = protocol.getLogsAsStrings()
    
            ioDict = {'inputs': input_obj,
                      'outputs': output_obj,
                      'summary': summary,
                      'methods': methods, 
                      'status': status,
                      'logs_out': parseText(fOutString),
                      'logs_error': parseText(fErrString),
                      'logs_scipion': parseText(fScpnString)
                      }
            
    #        print "ioDict: ", ioDict
            jsonStr = json.dumps(ioDict, ensure_ascii=False)
        
    return HttpResponse(jsonStr, mimetype='application/javascript')
Пример #12
0
def update_prot_tree(request):
    project = loadProject(request)
    project_settings = project.getSettings()
    index = request.GET.get('index', None)

    # set the new protocol tree chosen
    views = project.getProtocolViews()
    project_settings.setProtocolView(views[int(index)])
    project_settings.write()

    return HttpResponse(content_type='application/javascript')
Пример #13
0
def elements_graph(request):
    if request.is_ajax():
        projectName = request.session["projectName"]
        project = loadProject(request)
        g = project.getSourceGraph()

        elmList = []
        for node in g.getNodes():
            elmList.append({"id": node.getName(), "label": node.getLabel()})

        jsonStr = json.dumps(elmList, ensure_ascii=False)
        return HttpResponse(jsonStr, mimetype="application/javascript")
Пример #14
0
def update_prot_tree(request):
    projectName = request.session['projectName']
    project = loadProject(request)
    project_settings = project.getSettings()
    index = request.GET.get('index', None)

    # set the new protocol tree chosen
    views = project.getProtocolViews()
    project_settings.setProtocolView(views[int(index)])
    project_settings.write()
        
    return HttpResponse(mimetype='application/javascript')
Пример #15
0
def run_table_graph(request):
    from pyworkflow.gui.tree import ProjectRunsTreeProvider
    
    try:
        projectName = request.session['projectName']
        project = loadProject(request)
        project_settings = project.getSettings()
        provider = ProjectRunsTreeProvider(project)
        
        runs = request.session['runs']
        runsNew = formatProvider(provider, "runs")
        
        refresh = False
        listNewElm = []
        
        if len(runs) != len(runsNew):
            print 'Change detected, different size'
            refresh = True
        else:
            for kx, vx in runs:
                for ky, vy in runsNew:
                    if kx == ky and vx != vy:
                        print 'Change detected', vx, vy
    #                   refresh = True
                        listNewElm.append(vy)
        if refresh:
            request.session['runs'] = runsNew
            
            # Get the selected runs stored in BD    
            selectedRuns = project_settings.runSelection
            
            # Get the run mode view (0:list / 1:graph / 2:small graph) stored in BD
            runsView = project_settings.runsView.get()
            
            context = {'runs': runsNew,
                       'columns': provider.getColumns(),
                       'runsView': runsView,
                       'selectedRuns' : selectedRuns}
            
            return render_to_response('project_content/run_table_graph.html', context)
        
        elif listNewElm:
            request.session['runs'] = runsNew
            jsonStr = json.dumps(listNewElm, ensure_ascii=False)
            return HttpResponse(jsonStr, mimetype='application/json')
        
        else:
            print "No changes detected"
            return HttpResponse("ok", mimetype='text/plain')
        
    except Exception:
        print "Stopped script"
        return HttpResponse("stop", mimetype='text/plain')
Пример #16
0
def save_selection(request):
    if request.is_ajax():
        mark = request.GET.get('mark', None)

        project = loadProject(request)
        project_settings = project.getSettings()

        # Set the selected runs stored in BD
        project_settings.runSelection.set(mark)

        project_settings.write()

    return HttpResponse(content_type='application/javascript')
Пример #17
0
def save_selection(request):
    if request.is_ajax():
        mark = request.GET.get('mark', None)
        
        projectName = request.session['projectName']
        project = loadProject(request)
        project_settings = project.getSettings()
        
        # Set the selected runs stored in BD    
        project_settings.runSelection.set(mark)
        
        project_settings.write()
        
    return HttpResponse(mimetype='application/javascript')
Пример #18
0
def object_graph(request):
    if request.is_ajax():
        boxList = request.GET.get("list")
        projectName = request.session["projectName"]
        project = loadProject(request)
        g = project.getSourceGraph()

        root = g.getRoot()
        root.w = 100
        root.h = 40
        root.item = WebNode("project", x=0, y=0)

        # Assign the width and height
        for box in boxList.split(","):
            id, w, h = box.split("-")
            node = g.getNode(id)
            if node is None:
                print "Get NONE node: i=%s" % id
            else:
                node.id = id
                node.w = float(w)
                node.h = float(h)

        lt = gg.LevelTree(g)
        lt.paint(createNode, createEdge)

        nodeList = []
        for node in g.getNodes():
            try:
                hx = node.w / 2
                hy = node.h / 2
                childs = [c.getName() for c in node.getChilds()]

                nodeList.append(
                    {
                        "id": node.getName(),
                        "x": node.item.x - hx,
                        "y": node.item.y - hy,
                        "status": None,
                        "color": "#ADD8E6",  # Lightblue
                        "childs": childs,
                    }
                )

            except Exception:
                print "Error with node: ", node.getName()
                raise

        jsonStr = json.dumps(nodeList, ensure_ascii=False)
        return HttpResponse(jsonStr, mimetype="application/javascript")
Пример #19
0
def object_info(request):
    if request.is_ajax():
        projectName = request.session['projectName']
        objId = request.GET.get('objectId', None)
        project = loadProject(request)
        obj = project.mapper.selectById(objId)
        
        ioDict = {'info': str(obj),
                  'created': obj.getObjCreation(),
                  'comment': obj.getObjComment()
                  }
        
        jsonStr = json.dumps(ioDict, ensure_ascii=False)
        
    return HttpResponse(jsonStr, mimetype='application/javascript')
Пример #20
0
def object_graph(request):
    if request.is_ajax():
        boxList = request.GET.get('list')
        projectName = request.session['projectName']
        project = loadProject(request)
        g = project.getSourceGraph()

        root = g.getRoot()
        root.w = 100
        root.h = 40
        root.item = WebNode('project', x=0, y=0)

        # Assign the width and height
        for box in boxList.split(','):
            id, w, h = box.split('-')
            node = g.getNode(id)
            if node is None:
                print "Get NONE node: i=%s" % id
            else:
                node.id = id
                node.w = float(w)
                node.h = float(h)

        lt = gg.LevelTree(g)
        lt.paint(createNode, createEdge)

        nodeList = []
        for node in g.getNodes():
            try:
                hx = node.w / 2
                hy = node.h / 2
                childs = [c.getName() for c in node.getChilds()]

                nodeList.append({
                    'id': node.getName(),
                    'x': node.item.x - hx,
                    'y': node.item.y - hy,
                    'status': None,
                    'color': '#ADD8E6',  # Lightblue
                    'childs': childs
                })

            except Exception:
                print "Error with node: ", node.getName()
                raise

        jsonStr = json.dumps(nodeList, ensure_ascii=False)
        return HttpResponse(jsonStr, mimetype='application/javascript')
Пример #21
0
def delete_protocol(request):
    if request.is_ajax():
        project = loadProject(request)
        list_id = request.GET.get('id', None).split(",")
        
        list_protocols = []
        for id in list_id:        
            protocol = project.getProtocol(int(id))
            list_protocols.append(protocol)
            
        try:
            project.deleteProtocol(*list_protocols)
            res = {'success' : 'Protocol deleted successful'}
        except Exception, ex:
            errors = [parseText(str(ex))]
            res = {'errors' : errors}
Пример #22
0
def object_graph(request):
    if request.is_ajax():
        boxList = request.GET.get('list')
        projectName = request.session['projectName']
        project = loadProject(request)
        g = project.getSourceGraph()
        
        root = g.getRoot()
        root.w = 100
        root.h = 40
        root.item = WebNode('project', x=0, y=0)
        
        # Assign the width and height
        for box in boxList.split(','):
            id, w, h = box.split('-')
            node = g.getNode(id)
            if node is None:
                print "Get NONE node: i=%s" % id
            else:
                node.id = id
                node.w = float(w)
                node.h = float(h)
        
        lt = gg.LevelTree(g)
        lt.paint(createNode, createEdge)
        
        nodeList = []
        for node in g.getNodes():
            try:
                hx = node.w / 2
                hy = node.h / 2
                childs = [c.getName() for c in node.getChilds()]
            
                nodeList.append({'id': node.getName(),
                                 'x': node.item.x - hx, 
                                 'y': node.item.y - hy,
                                 'status': None,
                                 'color': '#ADD8E6', # Lightblue
                                 'childs': childs})
                
            except Exception:
                    print "Error with node: ", node.getName()
                    raise
        
        jsonStr = json.dumps(nodeList, ensure_ascii=False)   
        return HttpResponse(jsonStr, mimetype='application/javascript')
Пример #23
0
def delete_protocol(request):
    if request.is_ajax():
        projectName = request.session["projectName"]
        project = loadProject(request)
        list_id = request.GET.get("id", None).split(",")

        list_protocols = []
        for id in list_id:
            protocol = project.getProtocol(int(id))
            list_protocols.append(protocol)

        try:
            project.deleteProtocol(*list_protocols)
            res = {"success": "Protocol deleted successful"}
        except Exception, ex:
            errors = [parseText(str(ex))]
            res = {"errors": errors}
Пример #24
0
def object_tree(request):
    from views_tree import getGraphClassesNode, TreeItem, populateObjTree
    from views_tree import convertObjTree

    # Get Project
    project = loadProject(request)

    # Obtain the classes graph
    classesGraph = getGraphClassesNode(project)

    # Organize the graph with childs
    root = TreeItem('root', 'root', '', '')
    populateObjTree(root, classesGraph.getRootNodes())

    # Convert tree object to html
    html = convertObjTree(root)

    return HttpResponse(html, content_type='application/javascript')
Пример #25
0
def copy_protocol(request):
    if request.is_ajax():
        projectName = request.session['projectName']
        project = loadProject(request)
        list_id = request.GET.get('id', None).split(",")
        
        list_protocols = []
        for id in list_id:        
            protocol = project.getProtocol(int(id))
            list_protocols.append(protocol)
        
        try:
            protocol = project.copyProtocol(list_protocols)
            
            res = {'success' : 'Protocol copied successful'}
        except Exception, ex:
            errors = [parseText(str(ex))]
            res = {'errors' : errors}
Пример #26
0
def object_tree(request):
    from views_tree import getGraphClassesNode, TreeItem, populateObjTree
    from views_tree import convertObjTree
    
    #Get Project
    projectName = request.session['projectName'] 
    project = loadProject(request) 
    
    #Obtain the classes graph
    classesGraph = getGraphClassesNode(project)
    
    #Organize the graph with childs
    root = TreeItem('root', 'root', '', '')
    populateObjTree(root, classesGraph.getRootNodes())
    
    #Convert tree object to html 
    html = convertObjTree(root)
    
    return HttpResponse(html, mimetype='application/javascript')
Пример #27
0
def data_content(request):        
    projectName = request.GET.get('projectName', None)
    
    manager = Manager()
    request.session['projectPath'] = manager.getProjectPath(projectName)
    project = loadProject(request)
    
    context = {'projectName': projectName,
               'editTool': getResourceIcon('edit_toolbar'),
               'graph_utils': getResourceJs('graph_utils'),
               'project_content_utils': getResourceJs('project_content_utils'),
               'data_content_utils': getResourceJs('data_content_utils'),
               'jquery_cookie': getResourceJs('jquery_cookie'),
               'jquery_treeview': getResourceJs('jquery_treeview'),
               'project_content_css':getResourceCss('project_content'),
               'view':'data'
               }
    
    context = base_flex(request, context)
    
    return render_to_response('data_content/data_content.html', context)
Пример #28
0
def launch_viewer(request):
    from views_util import loadProject
    from pyworkflow.em import findViewers, EMProtocol, EMObject
    
    projectName = request.session['projectName']
    project = loadProject(request)
    
    objectId = request.GET.get('objectId')
    if '::' in objectId:
        idParts = objectId.split("::")
        if idParts[1] != 'None':
            setObj = project.getObject(int(idParts[0]))
            if idParts[1].startswith('__attribute__'):
                attrName = idParts[1].replace('__attribute__', '')
                if setObj.hasAttribute(attrName):
                    obj = getattr(setObj, attrName)
                else:
                    obj = None
                    print "OBJ IS NONE!!"
            else:
                obj = setObj[int(idParts[1])]
        else:
            obj = project.getObject(int(idParts[0]))
    else:
        obj = project.getObject(int(objectId))
    
    if obj != None:
        if obj.isPointer():
            obj = obj.get()
        
        viewers = findViewers(obj.getClassName(), WEB_DJANGO)        
    
        if len(viewers) == 0:
            views = []
            
            if isinstance(obj, EMProtocol):
                for _, output in obj.iterOutputAttributes(EMObject):
                    objViewers = findViewers(output.getClassName(), WEB_DJANGO)
                    if objViewers:
                        views += objViewers[0](project=project)._visualize(output) or []
    
            if not views:
                views = [MessageView("No viewers found for object type: %s" % obj.getClassName())]                    
            
            urls = [viewToUrl(request, view) for view in views]
        else:
            viewerClass = viewers[0]
            # Lets assume if there is a viewer for the protocol
            # it will be a ProtocolViewer with a Form
            if issubclass(viewerClass, ProtocolViewer):
                viewer = viewerClass(project=project, protocol=obj)
                urls = [viewerForm(project, obj, viewer)]
            else:
                viewer = viewerClass(project=project)
                views = viewer._visualize(obj)
                urls = [viewToUrl(request, v) for v in views]
    else:
        views = [MessageView("Object not found to visualize")]
        urls = [viewToUrl(request, view) for view in views]
    
    jsonStr = json.dumps(urls, ensure_ascii=False)
        
    return HttpResponse(jsonStr, mimetype='application/javascript')
Пример #29
0
def protocol_info(request):
    from pyworkflow.web.app.views_util import parseText
    from pyworkflow.em.data import EMObject

    if request.is_ajax():
        jsonStr = ''
        #         projectName = request.session['projectName']
        protId = request.GET.get('protocolId', None)

        #         projectPath = request.session['projectPath']
        project = loadProject(request)

        if len(protId) > 0:
            protocol = project.getProtocol(int(protId))

            # PROTOCOL IO
            input_obj = [{
                'name':
                name,
                'nameId':
                attr.getNameId(),
                'id':
                attr.getObjId(),
                'info':
                str(attr.get()) if attr.isPointer() else str(attr)
            } for name, attr in protocol.iterInputAttributes()]

            output_obj = [{
                'name': name,
                'nameId': attr.getNameId(),
                'id': attr.getObjId(),
                'info': str(attr)
            } for name, attr in protocol.iterOutputAttributes(EMObject)]

            # PROTOCOL SUMMARY
            summary = parseText(protocol.summary())

            # PROTOCOL METHODS
            methods = parseText(protocol.methods())

            # STATUS
            status = protocol.status.get()

            # LOGS (ERROR & OUTPUT)
            fOutString, fErrString, fScpnString = protocol.getLogsAsStrings()

            ioDict = {
                'inputs': input_obj,
                'outputs': output_obj,
                'summary': summary,
                'methods': methods,
                'status': status,
                'logs_out': parseText(fOutString),
                'logs_error': parseText(fErrString),
                'logs_scipion': parseText(fScpnString)
            }

            #        print "ioDict: ", ioDict
            jsonStr = json.dumps(ioDict, ensure_ascii=False)

    return HttpResponse(jsonStr, mimetype='application/javascript')
Пример #30
0
def launch_viewer(request):
    from views_util import loadProject
    from pyworkflow.em import findViewers, EMProtocol, EMObject
    
    projectName = request.session['projectName']
    project = loadProject(request)
    
    objectId = request.GET.get('objectId')
    if '::' in objectId:
        idParts = objectId.split("::")
        if idParts[1] != 'None':
            setObj = project.getObject(int(idParts[0]))
            if idParts[1].startswith('__attribute__'):
                attrName = idParts[1].replace('__attribute__', '')
                if setObj.hasAttribute(attrName):
                    obj = getattr(setObj, attrName)
                else:
                    obj = None
                    print "OBJ IS NONE!!"
            else:
                obj = setObj[int(idParts[1])]
        else:
            obj = project.getObject(int(idParts[0]))
    else:
        obj = project.getObject(int(objectId))
    
    if obj != None:
        if obj.isPointer():
            obj = obj.get()
        
        viewers = findViewers(obj.getClassName(), WEB_DJANGO)        
    
        if len(viewers) == 0:
            views = []
            
            if isinstance(obj, EMProtocol):
                for _, output in obj.iterOutputAttributes(EMObject):
                    objViewers = findViewers(output.getClassName(), WEB_DJANGO)
                    if objViewers:
                        views += objViewers[0](project=project)._visualize(output) or []
    
            if not views:
                views = [MessageView("No viewers found for object type: %s" % obj.getClassName())]                    
            
            urls = [viewToUrl(request, view) for view in views]
        else:
            viewerClass = viewers[0]
            # Lets assume if there is a viewer for the protocol
            # it will be a ProtocolViewer with a Form
            if issubclass(viewerClass, ProtocolViewer):
                viewer = viewerClass(project=project, protocol=obj)
                urls = [viewerForm(project, obj, viewer)]
            else:
                viewer = viewerClass(project=project)
                views = viewer._visualize(obj)
                urls = [viewToUrl(request, v) for v in views]
    else:
        views = [MessageView("Object not found to visualize")]
        urls = [viewToUrl(request, view) for view in views]
    
    jsonStr = json.dumps(urls, ensure_ascii=False)
        
    return HttpResponse(jsonStr, mimetype='application/javascript')