Diff for /OSAS/OSA_system/OSAS_add.py between versions 1.7 and 1.16

version 1.7, 2003/12/10 20:12:52 version 1.16, 2004/03/21 15:49:45
Line 2 Line 2
   
   
 """Methoden zum hinzufügen von Dokumenten ins Archiv"""  """Methoden zum hinzufügen von Dokumenten ins Archiv"""
   from OSAS_helpers import readArchimedesXML 
 import archive  import archive
 import os  import os
 from Products.PageTemplates.PageTemplateFile import PageTemplateFile  from Products.PageTemplates.PageTemplateFile import PageTemplateFile
Line 9  from Products.PageTemplates.PageTemplate Line 10  from Products.PageTemplates.PageTemplate
 import string  import string
 import urllib  import urllib
 import xml.dom.minidom  import xml.dom.minidom
   from time import localtime,strftime
   
 #referencetypes=['Book','Bic','Journal Article','Manuscript','jiji']  #referencetypes=['Book','Bic','Journal Article','Manuscript','jiji']
   
Line 19  def add(self, no_upload=0): Line 21  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/zpt/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 35  def add(self, no_upload=0):
   
   
 def getISO():  def getISO():
       """ISO"""
       try:
         f=file('/usr/local/mpiwg/Zope/lib/python/Products/OSA_system/iso639-1.inc','r').readlines()          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')
         value=string.split(line,'\t')[0].encode('ascii','replace')          value=string.split(line,'\t')[0].encode('ascii','replace')
         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 52  def add2(self): Line 58  def add2(self):
   
     self.fields=self.bibdata[self.reftype]      self.fields=self.bibdata[self.reftype]
     self.isolist=getISO()      self.isolist=getISO()
       tmp=getISO().keys()
       tmp.sort()
       self.isokeys=tmp
         #listed=[ x for x in self.isolist.keys()]          #listed=[ x for x in self.isolist.keys()]
     #print listed      #print listed
         #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/zpt/OSAS_add_bibdata').__of__(self)
     return newtemplate()      return newtemplate()
     #return self.fields      #return self.fields
   
Line 97  def add3(self): Line 106  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/zpt/OSAS_add_naming').__of__(self)
         return newtemplate()          return newtemplate()
           
   
Line 111  def add4(self): Line 120  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/zpt/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/zpt/OSAS_add_metadata').__of__(self)
     return newtemplate()      return newtemplate()
   
 def add6(self):  def add6(self):
Line 133  def add6(self): Line 142  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/zpt/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 144  def add6(self): Line 153  def add6(self):
     f=open(metapath,'w')      f=open(metapath,'w')
     f.writelines(renderxml)      f.writelines(renderxml)
     f.close()      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'):      if self.REQUEST.SESSION.has_key('no_upload'):
                   
         #newtemplate2=PageTemplateFile('/usr/local/mpiwg/Zope/Extensions/done',"text/html").__of__(self)          #newtemplate2=PageTemplateFile('/usr/local/mpiwg/Zope/Extensions/done',"text/html").__of__(self)
Line 152  def add6(self): Line 162  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/zpt/OSAS_saved').__of__(self)
           
                   
         newtemplate2.content_type="text/html"          newtemplate2.content_type="text/html"
Line 162  def add6(self): Line 172  def add6(self):
         return newtemplate2()          return newtemplate2()
   
   
 from time import localtime,strftime  
   
 def date(self):  def date(self):
     return strftime("%d.%m.%Y",localtime())       return strftime("%d.%m.%Y",localtime()) 
Line 177  def addPresentation(self,path): Line 187  def addPresentation(self,path):
     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 198  def addPresentation(self,path): Line 212  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/zpt/addPresentation').__of__(self)
     return newtemplate()      return newtemplate()
   
 def addPresentation2(self):  def addPresentation2(self):
Line 237  def addText(self,path): Line 251  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/zpt/addText').__of__(self)
     return newtemplate()      return newtemplate()
   
 def addText2(self):  def addText2(self):
Line 361  def addImages(self,path): Line 375  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/zpt/OSAS_addImages').__of__(self)
     return newtemplate()      return newtemplate()
   
 def addImages2(self):  def addImages2(self):
Line 375  def addImages2(self): Line 389  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/zpt/OSAS_upload2').__of__(self)
     return newtemplate()      return newtemplate()
           
   
Line 428  def readArchimedesXML(folder): Line 442  def readArchimedesXML(folder):
         return dict[folder]          return dict[folder]
     else:      else:
         return ""          return ""
 def combineTextImage(self,path):  
     """gibt input formular zur erstellung des texttools meta tag aus"""  
     files = os.listdir(path)  
       
     texts=[]  
     imagefolders=[]  
     presentationfolders=[]  
   
     splitted=path.split("/")  
     externxml=readArchimedesXML(splitted[len(splitted)-1])  
       
     for filename in files:  
         #print "FN",filename  
         if archive.isdigilib2(path+"/"+filename):  
             imagefolders.append(filename)  
               
         if archive.isFullText(path,filename):  
             #print "HI"  
             texts.append(filename)  
         if archive.isPresentation(path,filename):  
             presentationfolders.append(filename)  
           
     dom=xml.dom.minidom.parse(path+"/index.meta")  
     try:  
         filelanguage=archive.getText(dom.getElementsByTagName('lang')[0].childNodes)  
     except:  
         filelanguage=""  
     self.REQUEST.SESSION['isolist']=getISO()  
     self.REQUEST.SESSION['path']=path  
     self.REQUEST.SESSION['texts']=texts  
     self.REQUEST.SESSION['imagefolders']=imagefolders  
     self.REQUEST.SESSION['presentationfolders']=presentationfolders  
     self.REQUEST.SESSION['filelanguage']=filelanguage  
     self.REQUEST.SESSION['externxml']=externxml  
   
     newtemplate=PageTemplateFile('Products/OSA_system/ImageandText').__of__(self)  
     return newtemplate()  
           
   
   
Line 521  def combineTextImage2(self,path): Line 499  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)
   
       
       if self.REQUEST.has_key('thumbtemplate'):
           if not self.REQUEST['thumbtemplate']=="":
               xsltnode=dom.createElement('thumbtemplate')
               xsltnodetext=dom.createTextNode(self.REQUEST['thumbtemplate'])
               xsltnode.appendChild(xsltnodetext)
               subnode.appendChild(xsltnode)
   
       if self.REQUEST.has_key('topbar'):
           if not self.REQUEST['topbar']=="":
               xsltnode=dom.createElement('toptemplate')
               xsltnodetext=dom.createTextNode(self.REQUEST['topbar'])
               xsltnode.appendChild(xsltnodetext)
               subnode.appendChild(xsltnode)
   
       if self.REQUEST.has_key('startpage'):
           if not self.REQUEST['startpage']=="":
               xsltnode=dom.createElement('startpage')
               xsltnodetext=dom.createTextNode(self.REQUEST['startpage'])
               xsltnode.appendChild(xsltnodetext)
               subnode.appendChild(xsltnode)
   
       if self.REQUEST.has_key('project'):
           if not self.REQUEST['project']=="":
               xsltnode=dom.createElement('project')
               xsltnodetext=dom.createTextNode(self.REQUEST['project'])
               xsltnode.appendChild(xsltnodetext)
               subnode.appendChild(xsltnode)
   
       if self.REQUEST.has_key('digiLibTemplate'):
           if not self.REQUEST['digiLibTemplate']=="":
               xsltnode=dom.createElement('digilibtemplate')
               xsltnodetext=dom.createTextNode(self.REQUEST['digiLibTemplate'])
               xsltnode.appendChild(xsltnodetext)
               subnode.appendChild(xsltnode)
               
     node.appendChild(subnode)      node.appendChild(subnode)
           
     try:      try:

Removed from v.1.7  
changed lines
  Added in v.1.16


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