--- OSAS/OSA_system/OSAS_add.py 2003/10/11 10:54:13 1.4 +++ OSAS/OSA_system/OSAS_add.py 2004/03/21 15:49:45 1.16 @@ -2,6 +2,7 @@ """Methoden zum hinzufügen von Dokumenten ins Archiv""" +from OSAS_helpers import readArchimedesXML import archive import os from Products.PageTemplates.PageTemplateFile import PageTemplateFile @@ -9,6 +10,7 @@ from Products.PageTemplates.PageTemplate import string import urllib import xml.dom.minidom +from time import localtime,strftime #referencetypes=['Book','Bic','Journal Article','Manuscript','jiji'] @@ -19,7 +21,7 @@ def add(self, no_upload=0): self.referencetypes=['Book','Journal Article','Manuscript'] - newtemplate=PageTemplateFile('Products/OSA_system/OSAS_add_new').__of__(self) + newtemplate=PageTemplateFile('Products/OSA_system/zpt/OSAS_add_new').__of__(self) self.REQUEST.SESSION['path']=self.REQUEST['path'] if no_upload==0: self.REQUEST.SESSION['no_upload']='yes' @@ -33,14 +35,18 @@ def add(self, no_upload=0): def getISO(): - f=file('/usr/local/mpiwg/Zope/lib/python/Products/OSA_system/iso639-1.inc','r').readlines() - ret={} - for lineraw in f: - line=lineraw.encode('ascii','replace') - value=string.split(line,'\t')[0].encode('ascii','replace') - key=string.split(line,'\t')[1].encode('ascii','replace') - - ret[key]=value + """ISO""" + try: + f=file('/usr/local/mpiwg/Zope/lib/python/Products/OSA_system/iso639-1.inc','r').readlines() + #f=file('OSA_system/iso639-1.inc','r').readlines() + ret={} + for lineraw in f: + line=lineraw.encode('ascii','replace') + value=string.split(line,'\t')[0].encode('ascii','replace') + key=string.split(line,'\t')[1].encode('ascii','replace') + ret[key]=value + except: + ret={} return ret def add2(self): @@ -52,12 +58,15 @@ def add2(self): self.fields=self.bibdata[self.reftype] self.isolist=getISO() + tmp=getISO().keys() + tmp.sort() + self.isokeys=tmp #listed=[ x for x in self.isolist.keys()] #print listed #sorted=listed.sort() #print sorted - newtemplate=PageTemplateFile('Products/OSA_system/OSAS_add_bibdata').__of__(self) + newtemplate=PageTemplateFile('Products/OSA_system/zpt/OSAS_add_bibdata').__of__(self) return newtemplate() #return self.fields @@ -97,7 +106,7 @@ def add3(self): self.REQUEST.SESSION['folder_name']=self.REQUEST.SESSION['path'] return add5(self) else: - newtemplate=PageTemplateFile('Products/OSA_system/OSAS_add_naming').__of__(self) + newtemplate=PageTemplateFile('Products/OSA_system/zpt/OSAS_add_naming').__of__(self) return newtemplate() @@ -111,12 +120,12 @@ def add4(self): self.REQUEST.SESSION['folder_name']=self.folder_name self.image_folder_name="pageimg" - newtemplate=PageTemplateFile('Products/OSA_system/OSAS_upload').__of__(self) + newtemplate=PageTemplateFile('Products/OSA_system/zpt/OSAS_upload').__of__(self) return newtemplate() def add5(self): """ADD INDEX.META""" - newtemplate=PageTemplateFile('Products/OSA_system/OSAS_add_metadata').__of__(self) + newtemplate=PageTemplateFile('Products/OSA_system/zpt/OSAS_add_metadata').__of__(self) return newtemplate() def add6(self): @@ -133,7 +142,7 @@ def add6(self): for tag in self.metadata.keys(): self.metadataprint=self.metadataprint+"<"+tag+">"+self.metadata[tag]+"\n" - newtemplate=PageTemplateFile('Products/OSA_system/index_meta').__of__(self) + newtemplate=PageTemplateFile('Products/OSA_system/zpt/index_meta').__of__(self) newtemplate.content_type="text/plain" renderxml = newtemplate() if self.REQUEST.SESSION.has_key('no_upload'): @@ -144,7 +153,8 @@ def add6(self): f=open(metapath,'w') f.writelines(renderxml) f.close() - os.chmod(metapath,0644) + os.chmod(metapath,0664) + os.popen('chmod -R 0775 %s'%self.add_metadata['archive-path']+"/"+self.add_metadata['folder_name']) if self.REQUEST.SESSION.has_key('no_upload'): #newtemplate2=PageTemplateFile('/usr/local/mpiwg/Zope/Extensions/done',"text/html").__of__(self) @@ -152,7 +162,7 @@ def add6(self): else: #print self.add_metadata['archive-path'] self.viewpath=re.search(r"/mpiwg/online/(.*)",self.add_metadata['archive-path']).group(1) - newtemplate2=PageTemplateFile('Products/OSA_system/OSAS_saved').__of__(self) + newtemplate2=PageTemplateFile('Products/OSA_system/zpt/OSAS_saved').__of__(self) newtemplate2.content_type="text/html" @@ -162,7 +172,7 @@ def add6(self): return newtemplate2() -from time import localtime,strftime + def date(self): return strftime("%d.%m.%Y",localtime()) @@ -177,7 +187,11 @@ def addPresentation(self,path): try: author=archive.getText(dom.getElementsByTagName('author')[0].childNodes) except: - author=archive.getText(dom.getElementsByTagName('Author')[0].childNodes) + try: + author=archive.getText(dom.getElementsByTagName('Author')[0].childNodes) + except: + author=archive.getText(dom.getElementsByTagName('Editor')[0].childNodes) + title=archive.getText(dom.getElementsByTagName('title')[0].childNodes) try: date=archive.getText(dom.getElementsByTagName('year')[0].childNodes) @@ -198,7 +212,7 @@ def addPresentation(self,path): yes """%(author,title,date) - newtemplate=PageTemplateFile('Products/OSA_system/addPresentation').__of__(self) + newtemplate=PageTemplateFile('Products/OSA_system/zpt/addPresentation').__of__(self) return newtemplate() def addPresentation2(self): @@ -223,7 +237,7 @@ def addPresentation2(self): os.mkdir(path+"/"+folder_name) except: """nothing""" - print "NAME:",file_name + #print "NAME:",file_name f=open(path+"/"+folder_name+"/"+file_name,"w") f.write(xmlinfo) f.close() @@ -237,7 +251,7 @@ def addText(self,path): """add fulltext to the path""" self.REQUEST.SESSION['existing_names']=['pageimg'] # to be done generate list of existing text files self.REQUEST.SESSION['path']=path - newtemplate=PageTemplateFile('Products/OSA_system/addText').__of__(self) + newtemplate=PageTemplateFile('Products/OSA_system/zpt/addText').__of__(self) return newtemplate() def addText2(self): @@ -336,13 +350,13 @@ def addTextExternal(self,path,texturl,ve writefile.close() #registrieren - print urllib.urlopen("http://nausikaa2.rz-berlin.mpg.de:86/cgi-bin/toc/admin/reg.cgi?path=%s"%path).readlines() + return urllib.urlopen("http://nausikaa2.rz-berlin.mpg.de:86/cgi-bin/toc/admin/reg.cgi?path=%s"%path).readlines() + - return "DONE:"+textpath+"/"+name def TextExternalError(text): firsts=text[0:10] - print firsts + #print firsts try: match=re.search(r".*> /tmp/sc.out &"% re.sub('/mpiwg/online/','',self.REQUEST['path']+"/"+self.REQUEST['image'])) #return self.REQUEST.RESPONSE.redirect(self.REQUEST['URL2']+'?path='+self.REQUEST['path'])