def jqueryListOnCollection(req): #Get request param: collectionId, start, cnt param = webUtils.paramWithDefault({u"collectionId":u"C:/",u"start":0,u"cnt":40}, req.getQueryInfo()) #Get collection from system, collection system contains cached collections and filesystem collections. #h.write("<!--") #print "hello" print param if not objTools.isUuid(param["collectionId"]): #param["collectionId"] = collectionListItems.jsIdEncoding(param["collectionId"]) param["collectionId"] = stringTools.jsIdDecoding(param["collectionId"]) #h.write(unicode(str(int(param["start"])))+unicode(str(int(param["cnt"])))) co = collectionManager.getCollection(param["collectionId"], req.getDbSys()).getRange(int(param["start"]), int(param["cnt"])) #Output #h.write(str(co)) #res = "" #h.write("-->") if True:#try: resList = collectionListItem(co, req) else:#except: pass #h = libs.html.response.html() #print "hello" #h.write("good") req.resp.genJsonHead() req.resp.write(json.dumps(resList, indent = 4)) #h.write(l.s) #print res req.resp.end()
def containerListJson(treeItemToPopulate, checkedItems = []): #print 'list in dirlist:',treeItemToPopulate.listNamedChildren() en = libs.platform.services.getEncodingService() r=[] try: d = treeItemToPopulate.listNamedChildren() for f in d: #print f, r itemId = f #not needed if jstree support ":" itemId = stringTools.jsIdEncoding(f) ff=treeItemToPopulate.getChildAbsPath(f) #print 'before get is container' if itemId in checkedItems: item["class"] = "jstree-checked" else: item = {} item["attr"] = {"id":itemId} item["data"] = d[f] item["fullPath"] = f if treeItemToPopulate.isContainer(ff): #r.append(u'<li id="%s" class="%s">%s</li>' % (itemId,itemClassWithCheckState,i)) item["children"] = [] item["state"] = "closed" r.append(item) #break except IOError:#Exception,e: r.append(u'<li id="%s" class="jstree-closed">Could not load directory: %s</a></li>' % str(e)) #print json.dumps(r, indent = 4) return json.dumps(r, indent = 4)
def containerListJson(treeItemToPopulate, start, cnt, isTree = False, req = None, checkedItems = []): #print 'list in dirlist:',treeItemToPopulate.listNamedChildren() #en = libs.platform.services.getEncodingService() r=[] try: d = treeItemToPopulate.listNamedChildren(start, cnt, isTree) for f in d: #print f, r itemId = f #not needed if jstree support ":" itemId = stringTools.jsIdEncoding(f) ff=treeItemToPopulate.getChildAbsPath(f) #print 'before get is container' encoded = urllib.quote(encodingTools.translateToPageEncoding(f)) if itemId in checkedItems: item["class"] = "jstree-checked" else: item = {} item["attr"] = {"id":itemId} item["data"] = d[f] item["fullPath"] = f item["utf8FullPath"] = encoded if treeItemToPopulate.isContainer(ff): #r.append(u'<li id="%s" class="%s">%s</li>' % (itemId,itemClassWithCheckState,i)) item["children"] = [] item["state"] = "closed" if not isTree: t = tagSys.getTagSysObj(req.getDbSys()) tList = t.getTags(f) item["tags"] = tList r.append(item) #break except IOError:#Exception,e: r.append(u'<li id="%s" class="jstree-closed">Could not load directory: %s</a></li>' % str(e)) #print json.dumps(r, indent = 4) return json.dumps(r, indent = 4)
encoded = urllib.quote(encodingTools.translateToPageEncoding(f)) item = {} if itemId in checkedItems: item["class"] = "jstree-checked" else: item = {} item["attr"] = {"id":itemId} item["data"] = d[f] item["fullPath"] = f item["utf8FullPath"] = encoded if treeItemToPopulate.isChildContainer(f): #r.append(u'<li id="%s" class="%s">%s</li>' % (itemId,itemClassWithCheckState,i)) item["children"] = [] item["state"] = "closed" if not isTree: #print f #print 'getting tree --------------------------', f try: tList = t.getTags(f) except: tList = [] item["tags"] = tList r.append(item) #break except IOError, e:#Exception,e: item = {} item["data"] = str(e) r.append(item) #print json.dumps(r, indent = 4) return json.dumps(r, indent = 4)