# HG changeset patch # User dwinter # Date 1330523222 -3600 # Node ID d801453fd85f64ce56d24a4ad59ae99946bee210 # Parent 82e72e034b0b4650448abf49762062ba3beb6522 getProjectsAndTagsAsCSV diff -r 82e72e034b0b -r d801453fd85f MPIWGThesaurus.py --- a/MPIWGThesaurus.py Wed Feb 29 09:29:17 2012 +0100 +++ b/MPIWGThesaurus.py Wed Feb 29 14:47:02 2012 +0100 @@ -233,6 +233,24 @@ redirect(RESPONSE,'manage_main') + def getProjectsAndTagsAsCSV(self,archived=1): + """alle projekte auch die nicht getaggten""" + retList=[] + for project in self.getProjectFields('WEB_title_or_short'): + proj = project[0] + p_name = project[1] + retProj=[] + if (not proj.isArchivedProject() and archived==1) or (proj.isArchivedProject() and archived==2): + retProj.append(self.utf8ify(p_name)) + retProj.append(self.utf8ify(proj.getContent('xdata_01'))) + retProj.append("|".join([person[1] for person in self.thesaurus.getPersonsFromProject(proj.getId())])) + retProj.append("|".join([person[1] for person in self.thesaurus.getHistoricalPlacesFromProject(proj.getId())])) + retProj.append("|".join([person[1] for person in self.thesaurus.getObjectsFromProject(proj.getId())])) + retProj.append("|".join(self.thesaurus.getTags(proj.getId()))) + retList.append("\t".join(retProj)) + + return "\n".join(retList); + def getProjectsAndTags(self): """projekte und tags""" @@ -244,7 +262,7 @@ # python:here.getProjectsWithTag('approaches',here.getTitle(level1))">my proj - # + # for subTag in self.tags.get(tag): projs = self.getProjectsWithTag(tag,subTag) @@ -707,6 +725,44 @@ logging.debug(retList) return "["+",".join(retList)+"]" + + + + def getTags(self,projectID,RESPONSE=None): + """get all selected tagList""" + + + logging.debug("asking:"+projectID) + + + apps = self.getApproaches()+ self.getDisciplines(); + retList=[] + for tagType in self.tags.keys(): + + logging.debug("asking tag::"+repr(tagType)) + + tags = getattr(self,"tags",None) + if tags is None: + continue; + + tagsStored=tags.get(tagType,None) + if tagsStored is None: + continue; + + for tag in tagsStored.keys(): #gehe durch alle gespeichteren approached + logging.debug("checking:"+tag) + currentTag = tagsStored.get(tag,None) + if currentTag is None: + continue + if currentTag.has_key(projectID): + retList.append(""" "%s" """%tag) + + if RESPONSE: + RESPONSE.setHeader('Content-Type', "application/json") + + logging.debug(retList) + return retList + def getDisciplines(self): self.disciplines=self.getEntriesFromTxt(self.disciplinesTxt)