Diff for /OSAS/OSA_system/OSAS_show.py between versions 1.1 and 1.18

version 1.1, 2003/09/25 15:25:08 version 1.18, 2004/04/08 16:50:01
Line 1 Line 1
 # Classes for displaying, browsing and organizing the archive  """ Classes for displaying, browsing and organizing the archive
   20040303 Needs configuration for rescaling thumbs
   
   """
   
   import addFolder
 from OFS.Folder import Folder  from OFS.Folder import Folder
 from OFS.SimpleItem import SimpleItem  from OFS.SimpleItem import SimpleItem
 from Products.PageTemplates.PageTemplateFile import PageTemplateFile  from Products.PageTemplates.PageTemplateFile import PageTemplateFile
 from Products.PageTemplates.PageTemplate import PageTemplate  from Products.PageTemplates.PageTemplate import PageTemplate
   from AccessControl import ClassSecurityInfo
   from Globals import InitializeClass
   
 class OSAS_ShowOnline(SimpleItem):  class OSAS_ShowOnline(SimpleItem):
       security=ClassSecurityInfo()
       
     """OnlineBrowser"""      """OnlineBrowser"""
     def __init__(self,id):      def __init__(self,id):
         """initialize a new instance"""          """initialize a new instance"""
Line 13  class OSAS_ShowOnline(SimpleItem): Line 21  class OSAS_ShowOnline(SimpleItem):
   
     meta_type="OSAS_ShowOnline"      meta_type="OSAS_ShowOnline"
   
       security.declareProtected('View','index_html')
     def index_html(self):      def index_html(self):
         """main view"""          """main view"""
         pt=PageTemplateFile('products/OSA_system/OSAS_ViewFiles.zpt').__of__(self)          pt=PageTemplateFile('Products/OSA_system/zpt/OSAS_ViewFiles.zpt').__of__(self)
         return pt()          return pt()
           
     def getfilesystem2(self,start,reload=0):      def getfilesystem2(self,start,reload=0):
Line 51  class OSAS_ShowOnline(SimpleItem): Line 60  class OSAS_ShowOnline(SimpleItem):
         self.tree(path).toggle(path,file)          self.tree(path).toggle(path,file)
         return self.REQUEST.RESPONSE.redirect(self.REQUEST['URL1']+"?path="+path)          return self.REQUEST.RESPONSE.redirect(self.REQUEST['URL1']+"?path="+path)
           
   InitializeClass(OSAS_ShowOnline)
   
 def manage_AddOSAS_ShowOnlineForm(self):  def manage_AddOSAS_ShowOnlineForm(self):
     """interface for adding the OSAS_root"""      """interface for adding the OSAS_root"""
     pt=PageTemplateFile('products/OSA_system/AddOSAS_ShowOnline.zpt').__of__(self)      pt=PageTemplateFile('Products/OSA_system/zpt/AddOSAS_ShowOnline.zpt').__of__(self)
     return pt()      return pt()
   
 def manage_AddOSAS_ShowOnline(self,id,RESPONSE=None):  def manage_AddOSAS_ShowOnline(self,id,RESPONSE=None):
Line 64  def manage_AddOSAS_ShowOnline(self,id,RE Line 75  def manage_AddOSAS_ShowOnline(self,id,RE
         RESPONSE.redirect('manage_main')          RESPONSE.redirect('manage_main')
   
   
   class OSAS_StoreOnline(SimpleItem):
       """Webfrontend für das Storagesystem"""
       security=ClassSecurityInfo()
       
       def __init__(self,id):
           """initialize a new instance"""
           self.id = id
   
       meta_type="OSAS_StoreOnline"
   
       security.declareProtected('View','index_html')
       def index_html(self):
           """main view"""
           pt=PageTemplateFile('Products/OSA_system/zpt/OSAS_StoreFiles.zpt').__of__(self)
           return pt()
   
       def readContexts(self,path):
           """Zeige Contexte"""
           if os.path.exists(path+"/index.meta"):
               
               return readContexts(path)
               
           else:
               
               return []
   
       def rescaleThumbs(self,path):
           """rescale thumbs of images in path"""
   
           os.popen("ssh nausikaa2.rz-berlin.mpg.de /usr/local/mpiwg/scripts/scaleomat.pl %s /mpiwg/temp/online/scaled/thumb 90 --replace >> /tmp/sc.out &"% re.sub('/mpiwg/online/','',self.REQUEST['path']))
   
           self.REQUEST.SESSION['path']=self.REQUEST['path']
           #return self.REQUEST.RESPONSE.redirect(self.REQUEST['URL1'])
           pt=PageTemplateFile('Products/OSA_system/zpt/OSAS_scaled.zpt').__of__(self)
           return pt()
   
       
       def getfilesystem2(self,start,reload=0):
       """load filesystem"""
   
       k=filesystem2(start,1)
       return k
   
       def tree(self,start):
       """get the filetree"""
       k=browse(start)
       return k
   
       def path_to_link_store(self,path):
           """generates navigation bar for viewfiles"""
           return path_to_link_store(self.REQUEST['URL'],path)
       
       def isdigilib2(self,path):
           """check if digilib"""
           return isdigilib2(path)
   
       def changeName(self,name):
           return changeName(name)
   
       def hasMetafile(self,path):
           return hasMetafile(path)
   
       def getMetafile(self,path):
           return getMetafile(path)
   
       def toggle_view(self,path,file):
           """Oeffnen bzw. schließen der Subfolders"""
           self.tree(path).toggle(path,file)
           return self.REQUEST.RESPONSE.redirect(self.REQUEST['URL1']+"?path="+path)
   
       def isFolder(self,path):
           """Test ob Eintrag ein Folder ist"""
           return isFolder(self,path)
       
       def isScannedDocument(self,path):
           """Test ob Eintrag ein Scanned Document ist"""
           return isScannedDocument(self,path)
   
       def isFullText(self,path,folder_name):
           """Test ob Eintrag ein Folder ist"""
           return isFullText(path,folder_name)
   
       def isPresentation(self,path,folder_name):
           """Test ob Eintrag ein Folder ist"""
           return isPresentation(path,folder_name)
   
       def date(self):
       return strftime("%d.%m.%Y",localtime()) 
   
       def addFolderForm(self,path):
           """add a new path"""
           pt=PageTemplateFile('Products/OSA_system/zpt/OSAS_addFolder.zpt').__of__(self)
           return pt()
   
       def showHelp(self,refType,genericTag):
           """helptext"""
           for reference in self.ZopeFind(self.standardMD):
               if reference[1].title==refType:
                   text=getattr(reference[1],'md_'+genericTag)[2]
                   return text
           return "NO EXPLANATION"
   
       def showHelpTag(self,url,reftype,item):
           """gen javascript for showhelp"""
           url2=url+'/showHelp?refType=%s&genericTag=%s'%(reftype,item)
           ret="""javascript:wd=window.open(\'%s\',\'Help\',\'width=300,height=250\');void(\'\');wd.focus();"""%url2
           return ret
   
       def addFolder(self,path,folder_name,description,archive_creation_date,creator):
           """add the folder to the filesystem and write the metadata files"""
           return addFolder.addFolder(self,path,folder_name,description,archive_creation_date,creator)
   
       def EditIndex(self,path):
           """Editiere das Index Metafile"""
           try:
               dom=xml.dom.minidom.parse(path+"/index.meta")
               indexmeta=dom.toxml()
           except:
               indexmeta=""
               
           self.REQUEST.SESSION['indexmeta']=indexmeta
           self.REQUEST.SESSION['path']=path
           newtemplate=PageTemplateFile('Products/OSA_system/zpt/editindex').__of__(self)
           return newtemplate()
   
       def EditIndex2(self):
           """Sichern der Aenderungen in Index.meta"""
           if not self.REQUEST.has_key('fileupload'):
               #newtext=urllib.unquote(self.REQUEST['indexmeta'])
               newtext=self.REQUEST['indexmeta']
              
           else:
               self.file_name=self.REQUEST['fileupload'].filename
               #newtext=self.REQUEST.form['fileupload'].read()
               # HACK DW
               newtext=self.REQUEST['indexmeta']
               
           indexmeta=file(self.REQUEST.SESSION['path']+"/index.meta","w")
           indexmeta.writelines(newtext)
           return self.REQUEST.response.redirect(self.REQUEST['URL1']+"?path="+self.REQUEST.SESSION['path'])
         
       def add_metafile(self):
           """nothing"""
           pt=PageTemplateFile('Products/OSA_system/zpt/OSAS_addmetadata.zpt').__of__(self)
           return pt()
   
   InitializeClass(OSAS_StoreOnline)
       
   def manage_AddOSAS_StoreOnlineForm(self):
       """interface for adding the OSAS_root"""
       pt=PageTemplateFile('Products/OSA_system/zpt/AddOSAS_StoreOnline.zpt').__of__(self)
       return pt()
   
   def manage_AddOSAS_StoreOnline(self,id,RESPONSE=None):
       """add the OSAS_root"""
       newObj=OSAS_StoreOnline(id)
       self._setObject(id,newObj)
       if RESPONSE is not None:
           RESPONSE.redirect('manage_main')
   
   
   
   
   def readContexts(path):
       """ReadContext from index.meta"""
       dom=xml.dom.minidom.parse(path+"/index.meta")
       nodes=dom.getElementsByTagName('context')
       ret=[]
       
       
       for node in nodes:
           try:
               link=getText(node.getElementsByTagName('link')[0].childNodes)
               name=getText(node.getElementsByTagName('name')[0].childNodes)
               ret.append((link,name))
           except:
               """nothing"""
       return ret
   
   
 ### Ab hier Baustelle  ### Ab hier Baustelle
   
Line 79  from AccessControl import ClassSecurityI Line 267  from AccessControl import ClassSecurityI
 from AccessControl.Role import RoleManager  from AccessControl.Role import RoleManager
 from Acquisition import Implicit  from Acquisition import Implicit
 from Globals import Persistent  from Globals import Persistent
   try:
 from time import strptime  from time import strptime
   except:
       print "ignoring time.strptime import"
       
 from time import strftime  from time import strftime
 import time  import time
 import os.path  import os.path
Line 210  class filesystem(Implicit, Persistent, R Line 402  class filesystem(Implicit, Persistent, R
   
       def archive_the_path(self,path):        def archive_the_path(self,path):
            """parse indexmeta and return digilib path"""             """parse indexmeta and return digilib path"""
              
            try:             try:
                  #f = os.popen("cat "+path+"/index.meta","r")                   #f = os.popen("cat "+path+"/index.meta","r")
                  f =file(path+"/index.meta","r")                   f =file(path+"/index.meta","r")
Line 218  class filesystem(Implicit, Persistent, R Line 411  class filesystem(Implicit, Persistent, R
                         
                  try:                   try:
                        dom = xml.dom.minidom.parseString(lines)                         dom = xml.dom.minidom.parseString(lines)
                          if dom.getElementsByTagName("content-type"):
                        if getText(dom.getElementsByTagName("content-type")[0].childNodes)=="folder":                         if getText(dom.getElementsByTagName("content-type")[0].childNodes)=="folder":
                              """folder nicht archivieren"""                               """folder nicht archivieren"""
                              return 0                               return 0
                        else:                             
                              archive_storage_date=getText(dom.getElementsByTagName("archive-storage-date")[0].childNodes)                               archive_storage_date=getText(dom.getElementsByTagName("archive-storage-date")[0].childNodes)
                         
                              if archive_storage_date=="":                               if archive_storage_date=="":
Line 310  class filesystem2(Implicit, Persistent, Line 504  class filesystem2(Implicit, Persistent,
             
       def getfs(self,start):        def getfs(self,start):
         """load filessystem"""          """load filessystem"""
           
         f = os.popen("find "+ start+" -name '*' ","r")          f = os.popen("find "+ start+" -name '*' ","r")
     lines = f.readlines()      lines = f.readlines()
           
Line 445  class browse(Implicit, Persistent, RoleM Line 640  class browse(Implicit, Persistent, RoleM
               
 def getfs(start):  def getfs(start):
     """return filesystem"""      """return filesystem"""
           
   
         f = os.popen("find "+ start+" -name '*'","r")          f = os.popen("find "+ start+" -name '*'","r")
     lines = f.readlines()      lines = f.readlines()
         return lines          return lines
Line 535  def path_to_link_view(URL,path): Line 732  def path_to_link_view(URL,path):
       i=i-1        i=i-1
     return string      return string
   
 def path_to_link_store(path):  def path_to_link_store(URL,path):
     """generates navigation bar for viewfiles"""      """generates navigation bar for viewfiles"""
     string=""      string=""
           
Line 552  def path_to_link_store(path): Line 749  def path_to_link_store(path):
           tmppath=os.path.dirname(tmppath)            tmppath=os.path.dirname(tmppath)
   
     while i>=0:      while i>=0:
           string=string+"<a href=storefiles?path="+pathes[i][0]+">"+pathes[i][1]+"</a>/"            string=string+"<a href="+URL+"?path="+pathes[i][0]+">"+pathes[i][1]+"</a>/"
               
       i=i-1        i=i-1
     return string      return string
Line 705  def getText(nodelist): Line 902  def getText(nodelist):
   
 def getBib(nodelist):  def getBib(nodelist):
     rc= "<table border='0'>"      rc= "<table border='0'>"
     print "HI"      
     for node in nodelist:      for node in nodelist:
                   
         if node.nodeType == node.ELEMENT_NODE:          if node.nodeType == node.ELEMENT_NODE:
Line 715  def getBib(nodelist): Line 912  def getBib(nodelist):
     return rc+"</table>"      return rc+"</table>"
   
 def getMetafile(path):  def getMetafile(path):
     """get index.meta"""      """get index.meta and translate it to an HTML"""
     html=[]      html=[]
     if not os.path.exists(path+"/index.meta"):      if not os.path.exists(path+"/index.meta"):
                       
Line 724  def getMetafile(path): Line 921  def getMetafile(path):
        f = os.popen("cat "+path+"/index.meta","r")         f = os.popen("cat "+path+"/index.meta","r")
        lines = f.read()         lines = f.read()
        dom = xml.dom.minidom.parseString(lines)         dom = xml.dom.minidom.parseString(lines)
          try:
        name=getText(dom.getElementsByTagName("name")[0].childNodes)          name=getText(dom.getElementsByTagName("name")[0].childNodes) 
          except:
              name="NOT_DEFINED!!!"
          try:
        creator=getText(dom.getElementsByTagName("creator")[0].childNodes)            creator=getText(dom.getElementsByTagName("creator")[0].childNodes)   
          except:
              creator="NOT_DEFINED!!!"
   
          try:
        creation_date=getText(dom.getElementsByTagName("archive-creation-date")[0].childNodes)          creation_date=getText(dom.getElementsByTagName("archive-creation-date")[0].childNodes) 
          except:
              creation_date="NOT_DEFINED!!!"
   
          try:
        description=getText(dom.getElementsByTagName("description")[0].childNodes)          description=getText(dom.getElementsByTagName("description")[0].childNodes) 
          except:
              description="NOT_DEFINED!!!"
              
        try:         try:
         type=getText(dom.getElementsByTagName("content-type")[0].childNodes)           type=getText(dom.getElementsByTagName("content-type")[0].childNodes) 
        except:         except:
Line 748  def getMetafile(path): Line 960  def getMetafile(path):
     else:      else:
       html=html+"<h4>Info</h4>"        html=html+"<h4>Info</h4>"
         html=html+getBib(bib.childNodes)          html=html+getBib(bib.childNodes)
         print html          
        except:         except:
         """none"""          """none"""
                 
Line 761  def hasMetafile(path): Line 973  def hasMetafile(path):
     return os.path.exists(path+"/index.meta")      return os.path.exists(path+"/index.meta")
     #return path      #return path
   
   
   
 def isdigilib2(path):  def isdigilib2(path):
       """check if folder is candidate for digilib without metadata"""         """check if folder is candidate for digilib without metadata""" 
           try:            try:
Line 986  def date(self): Line 1200  def date(self):
   
               
               
 def EditIndex(self,path):  
       try:  
             dom=xml.dom.minidom.parse(path+"/index.meta")  
             indexmeta=dom.toxml()  
       except:  
             indexmeta=""  
       self.REQUEST.SESSION['indexmeta']=indexmeta  
       self.REQUEST.SESSION['path']=path  
       newtemplate=PageTemplateFile('/usr/local/mpiwg/Zope/Extensions/editindex').__of__(self)  
       return newtemplate()  
   
 def EditIndex2(self):  
       if not self.REQUEST.has_key('fileupload'):  
             #newtext=urllib.unquote(self.REQUEST['indexmeta'])  
             newtext=self.REQUEST['indexmeta']  
             print newtext  
       else:  
             self.file_name=self.REQUEST['fileupload'].filename  
             #newtext=self.REQUEST.form['fileupload'].read()  
             # HACK DW  
             newtext=self.REQUEST['indexmeta']  
         
       indexmeta=file(self.REQUEST.SESSION['path']+"/index.meta","w")  
       indexmeta.writelines(newtext)  
       return self.REQUEST.response.redirect("storage/storefiles?path="+self.REQUEST.SESSION['path'])  
   
       

Removed from v.1.1  
changed lines
  Added in v.1.18


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