--- cdli/cdli_files.py 2006/11/14 17:02:59 1.51 +++ cdli/cdli_files.py 2006/12/22 11:56:08 1.53 @@ -21,7 +21,7 @@ from ZPublisher.HTTPRequest import HTTPR from ZPublisher.HTTPResponse import HTTPResponse from ZPublisher.BaseRequest import RequestContainer import threading - +from BTrees.OOBTree import OOBTree class BasketContent(SimpleItem): """classe fuer den Inhalt eines Baskets""" @@ -1307,7 +1307,12 @@ class CDLIFileObject(CatalogAware,extVer return True security.declarePublic('view') - + + def getFormattedData(self): + """fromat text""" + data=self.getData() + return re.sub("\s\#lem"," #lem",data) #remove return vor #lem + def view(self): """view file""" pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','viewCDLIFile.zpt')).__of__(self) @@ -1393,6 +1398,10 @@ class CDLIFile(extVersionedFile,CatalogA """get last version data""" return self.getLastVersion().getData() + def getLastVersionFormattedData(self): + """get last version data""" + return self.getLastVersion().getFormattedData() + #security.declarePublic('history') @@ -1853,6 +1862,56 @@ class CDLIRoot(Folder): meta_type="CDLIRoot" downloadCounterBaskets=0# counts the current basket downloads if counter > 10 no downloads are possible + def showInLineIndex(self): + """get the index for debug purposes""" + print "show" + for x in self.lineIndex.iterkeys(): + print "word:",x + for y in self.lineIndex[x].iterkeys(): + print "doc",y,self.lineIndex[x][y] + + return self.lineIndex + + def searchInLineIndexDocs(self,word): + """search occurences""" + return list(self.lineIndex.get(word.upper()).keys()) + + def getLinesFromIndex(self,word,doc): + """get lines""" + return self.lineIndex[word][doc] + + def cleanInLineIndex(self): + """delete InlineIndex""" + for x in list(self.lineIndex.keys()): + del(self.lineIndex[x]) + print [x for x in self.lineIndex.keys()] + + return "ok" + + def storeInLineIndex(self,key,value): + """store in index""" + + if (not hasattr(self,'lineIndex')) or (type(self.lineIndex) is DictType): + self.lineIndex=OOBTree() + li=self.lineIndex + + if li.has_key(key): + + if li[key].has_key(value[0]) and (not (value[1] in li[key][value[0]])): + li[key][value[0]].append(value[1]) # add it if now in the array + else: + li[key][value[0]]=[value[1]] # new array for lines + + else: + + li[key]=OOBTree()# new btree for lines + li[key][value[0]]=[value[1]] + + + self.lineIndex=li + + get_transaction().commit() + def showFile(self,fileId): """show a file""" @@ -1860,7 +1919,7 @@ class CDLIRoot(Folder): if not f: return "" - return f[0].getObject().getLastVersionData() + return f[0].getObject().getLastVersionFormattedData() def URLquote(self,str): """quote url"""