--- cdli/cdli_files.py 2008/01/02 16:58:12 1.80.2.12 +++ cdli/cdli_files.py 2008/01/21 17:06:21 1.80.2.19 @@ -99,7 +99,7 @@ def formatAtfFullLineNum(txt, nolemma=Tr ret = [] surf = "" col = "" - for line in txt.split("\n"): + for line in txt.splitlines(): line = unicodify(line) if line and line[0] == '@': # surface or column @@ -108,7 +108,7 @@ def formatAtfFullLineNum(txt, nolemma=Tr surf = line.replace(words[0],surfaces[words[0]]).strip() elif words[0] == '@column': - col = words[1] + col = ' '.join(words[1:]) elif line and line[0] in '123456789': # ordinary line -> add line number @@ -144,14 +144,6 @@ def generateXMLReturn(hash): return ret - - - - - - - - def unique(s): """Return a list of the elements in s, but without duplicates. @@ -640,7 +632,7 @@ class CDLIBasketContainer(OrderedFolder) ret+=str(object[0].getData())+"\n" elif current=="yes": #search current object - logging.info("crrent: %s"%object[1].getId().split(".")[0]) + logging.debug("current: %s"%object[1].getId().split(".")[0]) founds=self.CDLICatalog.search({'title':object[1].getId().split(".")[0]}) if len(founds)>0: ret+=str(founds[0].getObject().getLastVersion().getData())+"\n" @@ -1520,6 +1512,12 @@ class CDLIFileObject(CatalogAware,extVer security.declareProtected('manage','index_html') + security.declarePublic('view') + view = PageTemplateFile('zpt/viewCDLIFile.zpt', globals()) + + security.declarePublic('editATF') + editATF = PageTemplateFile('zpt/editATFFile.zpt', globals()) + def PrincipiaSearchSource(self): """Return cataloguable key for ourselves.""" return str(self) @@ -1534,11 +1532,12 @@ class CDLIFileObject(CatalogAware,extVer def makeThisVersionCurrent(self,comment,author,RESPONSE=None): """copy this version to current""" parent=self.aq_parent - newversion=parent.manage_addCDLIFileObject('',comment,author) - newversion.manage_upload(self.getData()) + parent.manage_addVersionedFileObject(id=None,vC=comment,author=author,file=self.getData(),RESPONSE=RESPONSE) + #newversion=parent.manage_addCDLIFileObject('',comment,author) + #newversion.manage_upload(self.getData()) - if RESPONSE is not None: - RESPONSE.redirect(self.aq_parent.absolute_url()+'/history') + #if RESPONSE is not None: + # RESPONSE.redirect(self.aq_parent.absolute_url()+'/history') return True @@ -1548,11 +1547,6 @@ class CDLIFileObject(CatalogAware,extVer # return re.sub("\s\#lem"," #lem",data) #remove return vor #lem return re.sub("#lem"," #lem",data) #remove return vor #lem - security.declarePublic('view') - def view(self): - """view file""" - pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','viewCDLIFile.zpt')).__of__(self) - return pt() security.declarePublic('getPNumber') def getPNumber(self): @@ -1581,6 +1575,7 @@ class CDLIFileObject(CatalogAware,extVer return txt.group(2) except: return "ERROR" + manage_addCDLIFileObjectForm=DTMLFile('dtml/fileAdd', globals(),Kind='CDLIFileObject',kind='CDLIFileObject', version='1') @@ -1797,6 +1792,7 @@ def splitatf(fh,dir=None,ext=None): nf=None i=0 + #ROC: why split \n first and then \r??? if (type(fh) is StringType) or (type(fh) is UnicodeType): iter=fh.split("\n") else: @@ -1868,13 +1864,17 @@ class CDLIFileFolder(extVersionedFileFol setattr(self,name,value) + deleteFileForm = PageTemplateFile("zpt/doDeleteFile", globals()) - def delete(self,ids): + def delete(self,ids,REQUEST=None): """delete these files""" if type(ids) is not ListType: ids=[ids] self.manage_delObjects(ids) + + if REQUEST is not None: + return self.index_html() def getVersionNumbersFromIds(self,ids): @@ -2193,7 +2193,7 @@ class CDLIRoot(Folder): # compile into regexp objects and escape parens wordlist = [re.compile(splitexp%re.escape(w)) for w in word.split(' ')] - for line in file.split("\n"): + for line in file.splitlines(): for word in wordlist: #logging.debug("showwordinfile: searching for %s in %s"%(word.pattern,ignoreable.sub('',line))) if word.search(ignorable.sub('',line)): @@ -2238,11 +2238,20 @@ class CDLIRoot(Folder): # split search terms again (for grapheme search with words) splitwords = dict(((w,self.splitter[indexName].process([w])) for w in words)) - for line in file.split("\n"): + for line in file.splitlines(): line = unicodify(line) - # ignore lemma lines + # ignore lemma and other lines if line.lstrip().startswith('#lem:'): continue + # ignore p-num line + if line.startswith('&P'): + continue + # ignore version lines + if line.startswith('#version'): + continue + # ignore atf type lines + if line.startswith('#atf:'): + continue # first scan hitwords = []