comparison MPIWGThesaurus.py @ 35:cfb5bb05253a

direct oeffne des thesaurus mit neuem parameter open
author dwinter
date Thu, 24 Oct 2013 14:46:22 +0200
parents 911defd02ff8
children e13200d8d473
comparison
equal deleted inserted replaced
34:0b58b298ef44 35:cfb5bb05253a
643 transaction.commit() 643 transaction.commit()
644 644
645 def getTitle(self,entry): 645 def getTitle(self,entry):
646 return entry.title 646 return entry.title
647 647
648 def thes_quote(self,txt):
649 import md5
650 logging.debug("@*%s*@"%txt)
651 return md5.md5(txt.lower()).hexdigest()
652
653
654 def formatTag(self,tag):
655 splitted= tag.split("_")
656 return splitted[-1]
657
648 def getEntriesFormatted(self,entries,formatType): 658 def getEntriesFormatted(self,entries,formatType):
649 if not hasattr(self,'levelFormatted'): 659 if not hasattr(self,'levelFormatted'):
650 pt=PageTemplateFile('zpt/levelFormatted', globals()).__of__(self) 660 pt=PageTemplateFile('zpt/levelFormatted', globals()).__of__(self)
651 return pt(level1_entries=entries,type=formatType) 661 return pt(level1_entries=entries,type=formatType)
652 662
655 665
656 666
657 #return self.levelFormatted(level1_entries=entries,type=formatType) 667 #return self.levelFormatted(level1_entries=entries,type=formatType)
658 668
659 def getEntries(self,entry): 669 def getEntries(self,entry):
660 logging.debug("GETENTRY:"+repr(entry)) 670 #logging.debug("GETENTRY:"+repr(entry))
661 return entry.entries 671 return entry.entries
662 672
663 #nimmt ein eine Text der Form 673 #nimmt ein eine Text der Form
664 # TAG1 674 # TAG1
665 # --- 675 # ---
700 710
701 self.tagList=self.getEntriesFromTxt(self.approachesTxt) 711 self.tagList=self.getEntriesFromTxt(self.approachesTxt)
702 return self.tagList 712 return self.tagList
703 713
704 714
715 def getTagsAsHash(self,projectID,tagType=None):
716 """get all tags"""
717 retHash={}
718
719 tags = getattr(self,"tags",None)
720
721 if tags is None:
722 return;
723
724 #falls nicht gesetzt
725 if tagType is None:
726 tagTypes = tags.keys()
727 else:
728 tagTypes = [tagType]
729
730 for tagType in tagTypes:
731 retHash[tagType]=[]
732 tagsStored=tags.get(tagType,None)
733
734 if tagsStored is None:
735 return;
736
737 for tag in tagsStored.keys(): #gehe durch alle gespeichteren approached
738 logging.debug("checking:"+tag)
739 currentTag = tagsStored.get(tag,None)
740 if currentTag is None:
741 continue
742 if currentTag.has_key(projectID):
743 retHash[tagType].append("""%s"""%tag)
744
745 logging.debug(retHash)
746 return retHash
747
748
749
750
751
705 def getTagsJSON(self,projectID,tagType,RESPONSE=None): 752 def getTagsJSON(self,projectID,tagType,RESPONSE=None):
706 """get all selected tagList""" 753 """get all selected tagList"""
707 logging.debug("asking:"+projectID) 754 #logging.debug("asking:"+projectID)
708 logging.debug("asking tag::"+tagType) 755 #logging.debug("asking tag::"+tagType)
709 retList=[] 756 retList=[]
710 tags = getattr(self,"tags",None) 757 tags = getattr(self,"tags",None)
711 if tags is None: 758 if tags is None:
712 return; 759 return;
713 760
734 781
735 def getTags(self,projectID,projectTags,RESPONSE=None): 782 def getTags(self,projectID,projectTags,RESPONSE=None):
736 """get all selected tagList""" 783 """get all selected tagList"""
737 784
738 #projectTags = self.getProjectsAndTags() 785 #projectTags = self.getProjectsAndTags()
739 logging.debug(projectTags) 786 #logging.debug(projectTags)
740 787
741 project = projectTags.get(projectID) 788 project = projectTags.get(projectID)
742 if project is None: 789 if project is None:
743 project = projectTags.get("/en/research/projects/"+projectID) #TODO fix this projectTag list from getProjectsAndTags()contains fullpath 790 project = projectTags.get("/en/research/projects/"+projectID) #TODO fix this projectTag list from getProjectsAndTags()contains fullpath
744 if project is None: 791 if project is None: