Diff for /OSAS/OSA_system/OSAS_add.py between versions 1.2 and 1.9

version 1.2, 2003/10/05 18:16:19 version 1.9, 2004/01/21 07:43:01
Line 19  def add(self, no_upload=0): Line 19  def add(self, no_upload=0):
                   
     self.referencetypes=['Book','Journal Article','Manuscript']      self.referencetypes=['Book','Journal Article','Manuscript']
   
     newtemplate=PageTemplateFile('products/OSA_system/OSAS_add_new').__of__(self)      newtemplate=PageTemplateFile('Products/OSA_system/OSAS_add_new').__of__(self)
         self.REQUEST.SESSION['path']=self.REQUEST['path']          self.REQUEST.SESSION['path']=self.REQUEST['path']
     if no_upload==0:      if no_upload==0:
         self.REQUEST.SESSION['no_upload']='yes'          self.REQUEST.SESSION['no_upload']='yes'
Line 33  def add(self, no_upload=0): Line 33  def add(self, no_upload=0):
   
   
 def getISO():  def getISO():
         f=file('/Users/dwinter/Documents/Projekte/OSAS/OSA_system/iso639-1.inc','r').readlines()      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={}      ret={}
     for lineraw in f:      for lineraw in f:
         line=lineraw.encode('ascii','replace')          line=lineraw.encode('ascii','replace')
Line 41  def getISO(): Line 43  def getISO():
         key=string.split(line,'\t')[1].encode('ascii','replace')          key=string.split(line,'\t')[1].encode('ascii','replace')
                   
         ret[key]=value          ret[key]=value
       except:
           ret={}
         return ret          return ret
   
 def add2(self):  def add2(self):
Line 57  def add2(self): Line 61  def add2(self):
         #sorted=listed.sort()          #sorted=listed.sort()
     #print sorted      #print sorted
           
     newtemplate=PageTemplateFile('products/OSA_system/OSAS_add_bibdata').__of__(self)      newtemplate=PageTemplateFile('Products/OSA_system/OSAS_add_bibdata').__of__(self)
     return newtemplate()      return newtemplate()
     #return self.fields      #return self.fields
   
Line 97  def add3(self): Line 101  def add3(self):
         self.REQUEST.SESSION['folder_name']=self.REQUEST.SESSION['path']          self.REQUEST.SESSION['folder_name']=self.REQUEST.SESSION['path']
         return add5(self)          return add5(self)
     else:      else:
         newtemplate=PageTemplateFile('products/OSA_system/OSAS_add_naming').__of__(self)          newtemplate=PageTemplateFile('Products/OSA_system/OSAS_add_naming').__of__(self)
         return newtemplate()          return newtemplate()
           
   
Line 111  def add4(self): Line 115  def add4(self):
   
     self.REQUEST.SESSION['folder_name']=self.folder_name      self.REQUEST.SESSION['folder_name']=self.folder_name
     self.image_folder_name="pageimg"      self.image_folder_name="pageimg"
     newtemplate=PageTemplateFile('products/OSA_system/OSAS_upload').__of__(self)      newtemplate=PageTemplateFile('Products/OSA_system/OSAS_upload').__of__(self)
     return newtemplate()      return newtemplate()
           
 def add5(self):  def add5(self):
     """ADD INDEX.META"""      """ADD INDEX.META"""
     newtemplate=PageTemplateFile('products/OSA_system/OSAS_add_metadata').__of__(self)      newtemplate=PageTemplateFile('Products/OSA_system/OSAS_add_metadata').__of__(self)
     return newtemplate()      return newtemplate()
   
 def add6(self):  def add6(self):
Line 133  def add6(self): Line 137  def add6(self):
     for tag in self.metadata.keys():      for tag in self.metadata.keys():
         self.metadataprint=self.metadataprint+"<"+tag+">"+self.metadata[tag]+"</"+tag+">\n"          self.metadataprint=self.metadataprint+"<"+tag+">"+self.metadata[tag]+"</"+tag+">\n"
   
     newtemplate=PageTemplateFile('products/OSA_system/index_meta').__of__(self)      newtemplate=PageTemplateFile('Products/OSA_system/index_meta').__of__(self)
     newtemplate.content_type="text/plain"      newtemplate.content_type="text/plain"
     renderxml = newtemplate()      renderxml = newtemplate()
     if self.REQUEST.SESSION.has_key('no_upload'):      if self.REQUEST.SESSION.has_key('no_upload'):
Line 152  def add6(self): Line 156  def add6(self):
     else:      else:
                 #print self.add_metadata['archive-path']                  #print self.add_metadata['archive-path']
         self.viewpath=re.search(r"/mpiwg/online/(.*)",self.add_metadata['archive-path']).group(1)           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/OSAS_saved').__of__(self)
           
                   
         newtemplate2.content_type="text/html"          newtemplate2.content_type="text/html"
Line 173  def addPresentation(self,path): Line 177  def addPresentation(self,path):
           
     dom=xml.dom.minidom.parse(path+"/index.meta")      dom=xml.dom.minidom.parse(path+"/index.meta")
   
       
     try:      try:
         author=archive.getText(dom.getElementsByTagName('author')[0].childNodes)          author=archive.getText(dom.getElementsByTagName('author')[0].childNodes)
     except:      except:
           try:
         author=archive.getText(dom.getElementsByTagName('Author')[0].childNodes)          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)      title=archive.getText(dom.getElementsByTagName('title')[0].childNodes)
     try:      try:
         date=archive.getText(dom.getElementsByTagName('year')[0].childNodes)          date=archive.getText(dom.getElementsByTagName('year')[0].childNodes)
Line 197  def addPresentation(self,path): Line 206  def addPresentation(self,path):
     <display>yes</display>      <display>yes</display>
 </info>"""%(author,title,date)  </info>"""%(author,title,date)
           
     newtemplate=PageTemplateFile('products/OSA_system/addPresentation').__of__(self)      newtemplate=PageTemplateFile('Products/OSA_system/addPresentation').__of__(self)
     return newtemplate()      return newtemplate()
   
 def addPresentation2(self):  def addPresentation2(self):
Line 222  def addPresentation2(self): Line 231  def addPresentation2(self):
         os.mkdir(path+"/"+folder_name)          os.mkdir(path+"/"+folder_name)
     except:      except:
         """nothing"""          """nothing"""
     print "NAME:",file_name      #print "NAME:",file_name
     f=open(path+"/"+folder_name+"/"+file_name,"w")      f=open(path+"/"+folder_name+"/"+file_name,"w")
     f.write(xmlinfo)      f.write(xmlinfo)
     f.close()      f.close()
Line 236  def addText(self,path): Line 245  def addText(self,path):
     """add fulltext to the path"""      """add fulltext to the path"""
     self.REQUEST.SESSION['existing_names']=['pageimg'] # to be done generate list of existing text files      self.REQUEST.SESSION['existing_names']=['pageimg'] # to be done generate list of existing text files
     self.REQUEST.SESSION['path']=path      self.REQUEST.SESSION['path']=path
     newtemplate=PageTemplateFile('products/OSA_system/addText').__of__(self)      newtemplate=PageTemplateFile('Products/OSA_system/addText').__of__(self)
     return newtemplate()      return newtemplate()
   
 def addText2(self):  def addText2(self):
Line 335  def addTextExternal(self,path,texturl,ve Line 344  def addTextExternal(self,path,texturl,ve
     writefile.close()      writefile.close()
           
     #registrieren      #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):  def TextExternalError(text):
     firsts=text[0:10]      firsts=text[0:10]
     print firsts      #print firsts
     try:      try:
         match=re.search(r".*<?xml.*",firsts)          match=re.search(r".*<?xml.*",firsts)
     except:      except:
Line 360  def addImages(self,path): Line 369  def addImages(self,path):
     """Imagesfolder to the path"""      """Imagesfolder to the path"""
     self.REQUEST.SESSION['existing_names']=['pageimg'] # to be done generate list of existing pageimages files      self.REQUEST.SESSION['existing_names']=['pageimg'] # to be done generate list of existing pageimages files
     self.REQUEST.SESSION['path']=path      self.REQUEST.SESSION['path']=path
     newtemplate=PageTemplateFile('products/OSA_system/OSAS_addImages').__of__(self)      newtemplate=PageTemplateFile('Products/OSA_system/OSAS_addImages').__of__(self)
     return newtemplate()      return newtemplate()
   
 def addImages2(self):  def addImages2(self):
Line 374  def addImages2(self): Line 383  def addImages2(self):
     self.content_type='images'      self.content_type='images'
     addDirsToIndexMeta(self.REQUEST.SESSION['path'],self.image_folder_name,self.content_description,self.content_type)      addDirsToIndexMeta(self.REQUEST.SESSION['path'],self.image_folder_name,self.content_description,self.content_type)
     self.REQUEST.SESSION['path']=re.search(r"/mpiwg(.*)",self.REQUEST.SESSION['path']).group(1)      self.REQUEST.SESSION['path']=re.search(r"/mpiwg(.*)",self.REQUEST.SESSION['path']).group(1)
     newtemplate=PageTemplateFile('products/OSA_system/OSAS_upload2').__of__(self)      newtemplate=PageTemplateFile('Products/OSA_system/OSAS_upload2').__of__(self)
     return newtemplate()      return newtemplate()
           
   
Line 407  def addDirsToIndexMeta(path,folder_name, Line 416  def addDirsToIndexMeta(path,folder_name,
     writefile.write(dom.toxml().encode('utf-8'))      writefile.write(dom.toxml().encode('utf-8'))
     writefile.close()      writefile.close()
   
   def readArchimedesXML(folder):
       """gib URL aus """
       XML=urllib.urlopen("http://archimedes.mpiwg-berlin.mpg.de/cgi-bin/toc/toc.cgi?step=xmlcorpusmanifest").read()
       #print XML
       dom=xml.dom.minidom.parseString(XML)
       items=dom.getElementsByTagName('item')
       dict={}
       
       for item in items:
           #print item.attributes['dir'].value
           try:        
               dict[item.attributes['dir'].value]=item.attributes['xml'].value
               #print item.attributes['dir'].value,item.attributes['text'].value
           except:
               """nothing"""
           
       if dict.has_key(folder):
           return dict[folder]
       else:
           return ""
 def combineTextImage(self,path):  def combineTextImage(self,path):
     """gibt input formular zur erstellung des texttools meta tag aus"""      """gibt input formular zur erstellung des texttools meta tag aus"""
     files = os.listdir(path)      files = os.listdir(path)
Line 415  def combineTextImage(self,path): Line 444  def combineTextImage(self,path):
     imagefolders=[]      imagefolders=[]
     presentationfolders=[]      presentationfolders=[]
           
     for filename in files:      splitted=path.split("/")
       externxml=readArchimedesXML(splitted[len(splitted)-1])
                   
       for filename in files:
           #print "FN",filename
         if archive.isdigilib2(path+"/"+filename):          if archive.isdigilib2(path+"/"+filename):
             imagefolders.append(filename)              imagefolders.append(filename)
                           
         if archive.isFullText(path,filename):          if archive.isFullText(path,filename):
               #print "HI"
             texts.append(filename)              texts.append(filename)
         if archive.isPresentation(path,filename):          if archive.isPresentation(path,filename):
             presentationfolders.append(filename)              presentationfolders.append(filename)
Line 436  def combineTextImage(self,path): Line 469  def combineTextImage(self,path):
     self.REQUEST.SESSION['imagefolders']=imagefolders      self.REQUEST.SESSION['imagefolders']=imagefolders
     self.REQUEST.SESSION['presentationfolders']=presentationfolders      self.REQUEST.SESSION['presentationfolders']=presentationfolders
     self.REQUEST.SESSION['filelanguage']=filelanguage      self.REQUEST.SESSION['filelanguage']=filelanguage
     newtemplate=PageTemplateFile('products/OSA_system/ImageandText').__of__(self)      self.REQUEST.SESSION['externxml']=externxml
   
       newtemplate=PageTemplateFile('Products/OSA_system/ImageandText').__of__(self)
     return newtemplate()      return newtemplate()
           
   
Line 472  def combineTextImage2(self,path): Line 507  def combineTextImage2(self,path):
     if self.REQUEST.has_key('text'):                  if self.REQUEST.has_key('text'):            
         textfile=os.listdir(path+"/"+self.REQUEST['text'])[0]          textfile=os.listdir(path+"/"+self.REQUEST['text'])[0]
         textfoldernode=dom.createElement('text')          textfoldernode=dom.createElement('text')
         textfoldernodetext=dom.createTextNode(self.REQUEST['text']+"/"+textfile)          textfoldernodetext=dom.createTextNode(path+"/"+self.REQUEST['text']+"/"+textfile)
           textfoldernode.appendChild(textfoldernodetext)
           subnode.appendChild(textfoldernode)
   
       if self.REQUEST.has_key('external'):#USE CVS instead of local text
           textfoldernode=dom.createElement('text')
           textfoldernodetext=dom.createTextNode(self.REQUEST.SESSION['externxml'])
         textfoldernode.appendChild(textfoldernodetext)          textfoldernode.appendChild(textfoldernodetext)
         subnode.appendChild(textfoldernode)          subnode.appendChild(textfoldernode)
   
Line 488  def combineTextImage2(self,path): Line 529  def combineTextImage2(self,path):
         presentationnode.appendChild(presentationnodetext)          presentationnode.appendChild(presentationnodetext)
         subnode.appendChild(presentationnode)          subnode.appendChild(presentationnode)
           
   
       if self.REQUEST.has_key('xslt'):
           if not self.REQUEST['xslt']=="":
               xsltnode=dom.createElement('xslt')
               xsltnodetext=dom.createTextNode(self.REQUEST['xslt'])
               xsltnode.appendChild(xsltnodetext)
               subnode.appendChild(xsltnode)
   
     node.appendChild(subnode)      node.appendChild(subnode)
   
     # node=dom.getElementsByTagName('lang')[0] #getNode      try:
           node2=node.getElementsByTagName('bib')[0]
           subs=node2.getElementsByTagName('lang')
           for sub in subs:
               print "X",sub
               node2.removeChild(sub)
       except:
           """nothing"""
       try:
           main=dom.getElementsByTagName('bib')[0]
           node=dom.createElement('lang')
           textnode=dom.createTextNode(self.REQUEST['lang'])
           print "LANG:",lang
           node.appendChild(textnode)
           main.appendChild(node)
       except:
           try:
               subs=dom.getElementsByTagName('lang')
               main=dom.getElementsByTagName('resource')[0]
               for sub in subs:
                   main.removeChild(sub)
           except:
               """nothing"""
           
           try:
               main=dom.getElementsByTagName('resource')[0]
               node=dom.createElement('lang')
               textnode=dom.createTextNode(self.REQUEST['lang'])
               #print "LANG:",self.REQUEST['lang']
               node.appendChild(textnode)
               main.appendChild(node)
           except:
               """nothing"""
   
     writefile=file(path+"/index.meta","w")      writefile=file(path+"/index.meta","w")
     writefile.write(dom.toxml().encode('utf-8'))      writefile.write(dom.toxml().encode('utf-8'))
Line 500  def combineTextImage2(self,path): Line 581  def combineTextImage2(self,path):
   
     urllib.urlopen("http://nausikaa2.rz-berlin.mpg.de:86/cgi-bin/toc/admin/reg.cgi?path=%s"%path).readlines()      urllib.urlopen("http://nausikaa2.rz-berlin.mpg.de:86/cgi-bin/toc/admin/reg.cgi?path=%s"%path).readlines()
     #return urllib.quote("http://nausikaa2.rz-berlin.mpg.de:86/cgi-bin/toc/admin/reg.cgi?path=%s"%path)      #return urllib.quote("http://nausikaa2.rz-berlin.mpg.de:86/cgi-bin/toc/admin/reg.cgi?path=%s"%path)
     os.popen("ssh nausikaa2.rz-berlin.mpg.de /usr/local/mpiwg/scripts/scaleomat.pl %s /mpiwg/temp/online/scaled/thumb 90 &"% re.sub('mpiwg/online/','',self.REQUEST['path']+"/"+self.REQUEST['image']))      os.popen("ssh 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']))
     return self.REQUEST.RESPONSE.redirect(self.REQUEST['URL2']+'?path='+self.REQUEST['path'])      
       #return self.REQUEST.RESPONSE.redirect(self.REQUEST['URL2']+'?path='+self.REQUEST['path'])
           

Removed from v.1.2  
changed lines
  Added in v.1.9


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>