--- cdli/cdli_files.py 2007/03/23 17:15:36 1.75 +++ cdli/cdli_files.py 2007/04/27 14:22:33 1.77 @@ -26,6 +26,7 @@ import logging import transaction import copy import codecs +import sys def generateXMLReturn(hash): """erzeugt das xml file als returnwert fuer uploadATFRPC""" @@ -132,7 +133,7 @@ def unique(s): class BasketContent(SimpleItem): """classe fuer den Inhalt eines Baskets""" - + def __init__(self,content=[]): """content""" self.contentList=content[0:] @@ -530,6 +531,7 @@ class CDLIBasketContainer(OrderedFolder) return ret + security.declareProtected('manage','getBasketAsOneFile') def getBasketAsOneFile(self,basketName,current="no"): """returns all files of the basket combined in one file @param basketName: Name of the basket @@ -553,6 +555,7 @@ class CDLIBasketContainer(OrderedFolder) ret+=str(founds[0].getObject().getLastVersion().getData())+"\n" return ret + security.declareProtected('manage','upDateBaskets') def upDateBaskets(self): """update content in to objects""" @@ -623,7 +626,7 @@ class CDLIBasketContainer(OrderedFolder) return pt(basketId=basketId,basketName=basketName) - security.declareProtected('View','index_html') + security.declareProtected('manage','index_html') def index_html(self): """stanadard ansicht""" @@ -827,7 +830,7 @@ class CDLIBasketContainer(OrderedFolder) """get name of the actualuser""" return str(self.REQUEST['AUTHENTICATED_USER']) - + security.declareProtected('manage','addBasket') def addBasket(self,newBasketName): """add a new basket""" @@ -886,11 +889,12 @@ class CDLIBasket(Folder,CatalogAware): def searchInBasket(self,indexName,searchStr,regExp=False): """searchInBasket""" - lst=self.searchInLineIndexDocs(indexName,searchStr,uniq=True,regExp=False) + lst=self.searchInLineIndexDocs(indexName,searchStr,uniq=True,regExp=regExp) ret={} lv=self.getLastVersion() - logging.info("searching") + + for obj in lv.content.getContent(): id=obj[1].getId().split(".")[0] if id in lst: @@ -1239,7 +1243,7 @@ class CDLIBasketVersion(Implicit,Persist self.REQUEST.RESPONSE.setHeader("Content-Length",length) self.REQUEST.RESPONSE.write(ret) - security.declareProtected('View','downloadObjectsAsOneFile') + security.declareProtected('manage','downloadObjectsAsOneFile') def downloadObjectsAsOneFile(self,lock=None,procedure=None,REQUEST=None,check="yes",current="no"): """download all selected files in one file""" @@ -1371,7 +1375,7 @@ class CDLIBasketVersion(Implicit,Persist """get Comment""" return self.comment - security.declareProtected('View','index_html') + security.declareProtected('manage','index_html') def index_html(self): """view the basket""" @@ -1426,6 +1430,7 @@ class CDLIFileObject(CatalogAware,extVer security.declarePublic('makeThisVersionCurrent') + security.declareProtected('manage','index.html') def PrincipiaSearchSource(self): """Return cataloguable key for ourselves.""" return str(self) @@ -1534,6 +1539,7 @@ def manage_addCDLIFileObject(self,id,vC= class CDLIFile(extVersionedFile,CatalogAware): """CDLI file""" + security=ClassSecurityInfo() meta_type="CDLI file" default_catalog='CDLICatalog' @@ -1988,7 +1994,7 @@ class CDLIFileFolder(extVersionedFileFol return ret - security.declareProtected('View','index_html') + security.declareProtected('manage','index_html') def index_html(self): """main""" ext=self.ZopeFind(self,obj_ids=["index.html"]) @@ -2083,10 +2089,14 @@ class CDLIRoot(Folder): words=self.findWordRegExp(indexName,searchTerm) # suche nach allen Treffern logging.info("wd:%s"%words) for word in words: + ret+=self.searchInLineIndexDocs(indexName,word) - - return unique(ret) - + + + x= unique(ret) + logging.info("words_done") + return x + def showInLineIndex(self): """get the index for debug purposes""" print "show" @@ -2209,7 +2219,7 @@ class CDLIRoot(Folder): """get lines with word fromFileId""" file=self.showFile(fileId) - + logging.info("regEXP %s"%regExp) ret=[] if regExp: # wenn regexp dann generiere alle worte aus der list die der regexp entsprechen wordlist=self.findWordRegExp(indexName,word) @@ -2219,7 +2229,8 @@ class CDLIRoot(Folder): for line in file.split("\n"): found=False for word in wordlist: - if line.find(word)>-1: + try: # just a hack because of possible unicode errors in line + if line.find(word)>-1: if lineList: #liste of moeglichen Zeilennummern num=line.split(".")[0] #Zeilenummer ist alles vor dem . in der Zeile @@ -2230,6 +2241,8 @@ class CDLIRoot(Folder): ret.append(line) break; + except: + pass return ret def tagWordInFile(self,fileId,word,lineList=None,regExp=True,indexName=""):