def launch_viewer(request): project = loadProject(request) objectId = request.GET.get('objectId') # Fix this, now we should use newer notation: . instead of :: if '::' in objectId: idParts = objectId.split("::") if idParts[1] != 'None': # We use the logic in Pointer.get to handle the 'extended' # parts that can come as part of the id (eg: 2::outputAverages::1) protObj = project.getObject(int(idParts[0])) pointer = Pointer(value=protObj) pointer.setExtendedParts(idParts[1:]) obj = pointer.get() else: # obj = project.getObject(int(idParts[0])) else: obj = project.getObject(int(objectId)) if obj is not 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] viewer = viewerClass(project=project, protocol=obj) # Lets assume if there is a viewer for the protocol # it will be a ProtocolViewer with a Form if issubclass(viewerClass, ProtocolViewer): urls = [viewerForm(project, obj, viewer, request)] else: 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, content_type='application/javascript')