--- OSAS/OSA_system/OSAS_add.py 2004/04/18 19:42:12 1.29 +++ OSAS/OSA_system/OSAS_add.py 2005/01/20 13:38:02 1.40 @@ -52,7 +52,7 @@ def getISO(): ret={} for lineraw in f: - line=lineraw.encode('ascii','replace') + line=lineraw.encode('ascii','replace').strip() value=string.split(line,'\t')[0].encode('ascii','replace') key=string.split(line,'\t')[1].encode('ascii','replace') ret[key]=value @@ -137,16 +137,35 @@ def add3(self): def add4(self): + self.path=re.search(r"/mpiwg(.*)",self.REQUEST.SESSION['path']).group(1) self.folder_name=self.REQUEST['folder_name'] # next has to be changed -> error if back button is used!! self.REQUEST.SESSION['folder_name']=self.folder_name + #return self.REQUEST['submit'] + + try: + #os.popen('mkdir '+self.REQUEST.SESSION['path']) + os.mkdir(os.path.join(self.REQUEST.SESSION['path'],self.REQUEST['folder_name'])) + os.chmod(os.path.join(self.REQUEST.SESSION['path'],self.REQUEST['folder_name']),0775) + + except: + + """nothing""" + if self.REQUEST['submit']=="upload images": self.REQUEST.SESSION['path']=os.path.join(self.REQUEST.SESSION['path'],self.REQUEST['folder_name']) + + self.image_folder_name="pageimg" newtemplate=PageTemplateFile('Products/OSA_system/zpt/OSAS_upload').__of__(self) + return newtemplate() + + elif self.REQUEST['submit']=="upload pdf": + os.mkdir(os.path.join(self.REQUEST.SESSION['path'],self.REQUEST['folder_name'])) + return addPdf(self,os.path.join(self.REQUEST.SESSION['path'],self.REQUEST['folder_name'])) else: os.mkdir(os.path.join(self.REQUEST.SESSION['path'],self.REQUEST['folder_name'])) return addText(self,os.path.join(self.REQUEST.SESSION['path'],self.REQUEST['folder_name'])) @@ -154,6 +173,11 @@ def add4(self): def add5(self): """ADD INDEX.META""" + try: + os.chmod(self.REQUEST.SESSION['path'],0775) + except: + pass + newtemplate=PageTemplateFile('Products/OSA_system/zpt/OSAS_add_metadata').__of__(self) return newtemplate() @@ -174,14 +198,14 @@ def add6(self): newtemplate=PageTemplateFile('Products/OSA_system/zpt/index_meta').__of__(self) newtemplate.content_type="text/plain" - renderxml = newtemplate() + renderxml = newtemplate(encode='utf-8') if self.REQUEST.SESSION.has_key('no_upload'): metapath=self.REQUEST.SESSION['path']+"/index.meta" else: metapath=self.add_metadata['archive-path']+"/"+self.add_metadata['folder_name']+"/index.meta" f=open(metapath,'w') - f.writelines(renderxml) + f.write(renderxml.encode('utf-8')) f.close() os.chmod(metapath,0664) os.popen('chmod -R 0775 %s'%self.add_metadata['archive-path']+"/"+self.add_metadata['folder_name']) @@ -192,15 +216,16 @@ def add6(self): else: #print self.add_metadata['archive-path'] self.viewpath=re.search(r"/mpiwg/online/(.*)",self.add_metadata['archive-path']).group(1) - if not (self.REQUEST.SESSION['no_upload']=="text"): + + if (self.REQUEST.SESSION.has_key('no_upload')) and (self.REQUEST.SESSION['no_upload']=="text"): + """text upload""" + return 1 + else: newtemplate2=PageTemplateFile('Products/OSA_system/zpt/OSAS_saved').__of__(self) newtemplate2.content_type="text/html" self.REQUEST.response.setHeader('Content-Type','text/html') return newtemplate2() - else: - """text upload""" - return 1 - + def date(self): @@ -239,17 +264,21 @@ def addPresentation(self,path): except: date="" i=1 - while os.path.exists("%02d-presentation"%i): + while os.path.exists(path+"/%02d-presentation"%i): i+=1 self.REQUEST.SESSION['presentationname']="%02d-presentation"%i self.REQUEST.SESSION['path']=path - self.REQUEST.SESSION['xmlvorschlag']=""" + + tmpTxt=""" + %s %s %s yes """%(author,title,date) + self.REQUEST.SESSION['xmlvorschlag']=tmpTxt.encode('utf-8') + newtemplate=PageTemplateFile('Products/OSA_system/zpt/addPresentation').__of__(self) return newtemplate() @@ -280,15 +309,50 @@ def addPresentation2(self): f.write(xmlinfo) f.close() try: - os.chmod(path+"/"+folder_name,0755) + os.chmod(path+"/"+folder_name,0775) except: """NO""" - os.chmod(path+"/"+folder_name+"/"+file_name,0644) + os.chmod(path+"/"+folder_name+"/"+file_name,0664) addDirsToIndexMeta(path,folder_name,content_description,'presentation') return self.REQUEST.RESPONSE.redirect(self.REQUEST['URL2']+'?path='+path) + +def addPdf(self,path,folder=None): + """add fulltext to the path""" + self.REQUEST.SESSION['existing_names']=['pageimg'] # to be done generate list of existing text files + self.REQUEST.SESSION['pathnew']=path + newtemplate=PageTemplateFile('Products/OSA_system/zpt/addPdf').__of__(self) + return newtemplate() + +def addPdf2(self): + """addtext""" + folder_name="pdf" # foldername fixed + + if self.REQUEST['file_name']=="": + file_name=self.REQUEST['fileupload'].filename + else: + file_name=self.REQUEST['file_name'] + + #print self.REQUEST['folder_name'] + content_description=self.REQUEST['content_description'] + path=self.REQUEST.SESSION['pathnew'] + + filedata=self.REQUEST.form['fileupload'].read() + try: + os.mkdir(path+"/"+folder_name) + except: + """nothing""" + f=open(path+"/"+folder_name+"/"+file_name,"w") + f.write(filedata) + f.close() + os.chmod(path+"/"+folder_name,0755) + os.chmod(path+"/"+folder_name+"/"+file_name,0644) + addDirsToIndexMeta(path,folder_name,content_description,'pdf') + + return self.REQUEST.RESPONSE.redirect(self.REQUEST['URL2']+'?path='+path) + def addText(self,path,folder=None): """add fulltext to the path""" self.REQUEST.SESSION['existing_names']=['pageimg'] # to be done generate list of existing text files @@ -360,7 +424,7 @@ def addTextExternal(self,path,texturl,ve node.appendChild(subnode) writefile=file(path+"/index.meta","w") - writefile.write(dom.toxml().encode('utf-8')) + writefile.write(dom.toxml(encoding="UTF-8")) writefile.close() #change texttool tag @@ -389,7 +453,7 @@ def addTextExternal(self,path,texturl,ve #index.meta ausgeben writefile=file(path+"/index.meta","w") - writefile.write(dom.toxml().encode('utf-8')) + writefile.write(dom.toxml(encoding="UTF-8")) writefile.close() #registrieren @@ -462,7 +526,7 @@ def addDirsToIndexMeta(path,folder_name, node.appendChild(subnode) writefile=file(path+"/index.meta","w") - writefile.write(dom.toxml().encode('utf-8')) + writefile.write(dom.toxml(encoding='UTF-8')) writefile.close() def readArchimedesXML(folder): @@ -578,6 +642,13 @@ def combineTextImage2(self,path): xsltnodetext=dom.createTextNode(self.REQUEST['project']) xsltnode.appendChild(xsltnodetext) subnode.appendChild(xsltnode) + + if self.REQUEST.has_key('digiliburlprefix'): + if not self.REQUEST['digiliburlprefix']=="": + xsltnode=dom.createElement('digiliburlprefix') + xsltnodetext=dom.createTextNode(self.REQUEST['digiliburlprefix']) + xsltnode.appendChild(xsltnodetext) + subnode.appendChild(xsltnode) node.appendChild(subnode) @@ -614,7 +685,7 @@ def combineTextImage2(self,path): """nothing""" writefile=file(path+"/index.meta","w") - writefile.write(dom.toxml().encode('utf-8')) + writefile.write(dom.toxml(encoding="UTF-8")) writefile.close() @@ -622,11 +693,15 @@ def combineTextImage2(self,path): urllib.urlopen("http://nausikaa2.rz-berlin.mpg.de:86/cgi-bin/toc/admin/reg.cgi?path=%s"%path).readlines() if self.REQUEST.has_key('image'): # falls bilder - os.popen("ssh archive@nausikaa2.rz-berlin.mpg.de /usr/local/mpiwg/scripts/scaleomat.pl %s /mpiwg/temp/online/scaled/thumb 90 >> /tmp/sc.out &"% re.sub('/mpiwg/online/','',self.REQUEST['path']+"/"+self.REQUEST['image'])) + path=re.sub('//','/',self.REQUEST['path']) # falls '//' im Pfad + dlpath = re.sub('/mpiwg/online/','',path)+"/"+self.REQUEST['image'] + os.popen("ssh archive@nausikaa2.rz-berlin.mpg.de /usr/local/mpiwg/scripts/scaleomat -src=/mpiwg/online -dest=/mpiwg/temp/online/scaled/thumb -dir=%s -scaleto=90 -sync >> /tmp/sc.out &"%dlpath ) + #os.popen("ssh archive@nausikaa2.rz-berlin.mpg.de /usr/local/mpiwg/scripts/scaleomat.pl %s /mpiwg/temp/online/scaled/thumb 90 >> /tmp/sc.out &"% re.sub('/mpiwg/online/','',self.REQUEST['path']+"/"+self.REQUEST['image'])) else: # falls keine Bilder (bug in reg.cgi info file ersetzen) f=file("/tmp/tmp_info.xml","w") - f.write(patchedInfoXML(self.REQUEST['path'])) + tmp=patchedInfoXML(self.REQUEST['path']) + f.write(tmp.encode('utf-8')) f.close() splitted=path.split("/") fn=splitted[len(splitted)-1]