def _get_child_cls_obj(request, ws_id, parent): """ Get child for tree in GUI """ logger.debug("_get_child_cls_obj") result = [] spr = [] try: with views_kb._kb_session() as ses: ws = ses.workspace(ws_id) cls_dicts = [ views_kb._kbclass_to_dict(o, ses) for o in ses.classes(ws=ws, parent=parent, recurse=False) ] cls = ses.class_(parent, ws=ws) logger.info("cls_dicts") logger.info(cls_dicts) logger.info("PARENTTTT") logger.info(parent) #objs = ses.objects(class_=cls.python_class, ws=ws, recurse=False) objs = ses.objects(class_=cls.python_class) logger.info("objs") logger.info(objs) obj_dicts = [views_kb._kbobject_to_dict(o, ses) for o in objs] #--- FIXME:some problem with objs = ses.objects(class_=cls.python_class, ws=ws, recurse=False) -- logger.info("obj_dicts") logger.info(obj_dicts) objs_bis = [] for o in obj_dicts: print str(o['class_id']) print str(parent) if (str(o['class_id']) == str(parent)): objs_bis.append(o) #--- for c in cls_dicts: if len(c['subclasses']) > 0: tmp = _put_right_value_leaf(c, False) else: tmp = _put_right_value_leaf(c, False) result.append(tmp) for o in objs_bis: tmp = { 'text': o['name'], 'id': o['id'], 'leaf': True, } result.append(tmp) except Exception, ex: logger.debug(ex)
def get_specific_info_obj(request, obj_id): """ Return all information about obj passed. It's passed obj's id. """ with views_kb._kb_session() as ses: ws = ses.workspace(request.session['workspace'].pk) cls = ses.object(obj_id, ws=ws) rtr = {"rows": []} rtr['rows'].append(views_kb._kbobject_to_dict(cls, ses)) resp = simplejson.dumps(rtr) return HttpResponse(resp)
def get_specific_info_obj(request, obj_id): """ Return all information about obj passed. It's passed obj's id. """ with views_kb._kb_session() as ses: ws = ses.workspace(request.session['workspace'].pk) cls = ses.object(obj_id, ws=ws) rtr = {"rows":[]} rtr['rows'].append(views_kb._kbobject_to_dict(cls, ses)) resp = simplejson.dumps(rtr) return HttpResponse(resp)
def _get_child_cls_obj(request,ws_id, parent): """ Get child for tree in GUI """ logger.debug("_get_child_cls_obj") result = [] spr = [] try: with views_kb._kb_session() as ses: ws = ses.workspace(ws_id) cls_dicts = [views_kb._kbclass_to_dict(o, ses) for o in ses.classes(ws=ws, parent=parent, recurse=False)] cls = ses.class_(parent, ws=ws) logger.info("cls_dicts") logger.info(cls_dicts) logger.info("PARENTTTT") logger.info(parent) #objs = ses.objects(class_=cls.python_class, ws=ws, recurse=False) objs = ses.objects(class_=cls.python_class) logger.info("objs") logger.info(objs) obj_dicts = [views_kb._kbobject_to_dict(o, ses) for o in objs] #--- FIXME:some problem with objs = ses.objects(class_=cls.python_class, ws=ws, recurse=False) -- logger.info("obj_dicts") logger.info(obj_dicts) objs_bis = [] for o in obj_dicts: print str(o['class_id']) print str(parent) if (str(o['class_id']) == str(parent)): objs_bis.append(o) #--- for c in cls_dicts: if len(c['subclasses'])>0: tmp = _put_right_value_leaf(c, False) else: tmp = _put_right_value_leaf(c, False) result.append(tmp) for o in objs_bis: tmp = {'text' : o['name'], 'id': o['id'], 'leaf': True, } result.append(tmp) except Exception, ex: logger.debug(ex)
def get_object_attributes_hierarchy(request): """ Return all information about obj passed. It's passed obj id. """ nodes = tree_view._get_item_nodes(request.POST.getlist('items')) with views_kb._kb_session() as ses: rtr = {"rows":[]} for node in nodes: n = Node.objects.get(pk = node.id) while n.parent_id: if n.kb_object_id: cls = views_kb._kbobject_to_dict(ses.object(n.kb_object_id), ses) _put_attributes(cls,rtr) n = Node.objects.get(pk = n.parent_id) logger.debug(rtr) resp = simplejson.dumps(rtr) return HttpResponse(resp)
def get_object_attributes_hierarchy(request): """ Return all information about obj passed. It's passed obj id. """ nodes = tree_view._get_item_nodes(request.POST.getlist('items')) with views_kb._kb_session() as ses: rtr = {"rows": []} for node in nodes: n = Node.objects.get(pk=node.id) while n.parent_id: if n.kb_object_id: cls = views_kb._kbobject_to_dict( ses.object(n.kb_object_id), ses) _put_attributes(cls, rtr) n = Node.objects.get(pk=n.parent_id) logger.debug(rtr) resp = simplejson.dumps(rtr) return HttpResponse(resp)