Diff for /OSAS/OSA_system/OSAS_show.py between versions 1.10 and 1.20

version 1.10, 2003/12/19 15:05:41 version 1.20, 2004/04/15 20:48: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  import addFolder
   import OSAS_helpers
 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
Line 22  class OSAS_ShowOnline(SimpleItem): Line 25  class OSAS_ShowOnline(SimpleItem):
     security.declareProtected('View','index_html')      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 58  class OSAS_ShowOnline(SimpleItem): Line 61  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)  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 86  class OSAS_StoreOnline(SimpleItem): Line 90  class OSAS_StoreOnline(SimpleItem):
     security.declareProtected('View','index_html')      security.declareProtected('View','index_html')
     def index_html(self):      def index_html(self):
         """main view"""          """main view"""
         pt=PageTemplateFile('Products/OSA_system/OSAS_StoreFiles.zpt').__of__(self)          pt=PageTemplateFile('Products/OSA_system/zpt/OSAS_StoreFiles.zpt').__of__(self)
         return pt()          return pt()
   
     def readContexts(self,path):      def readContexts(self,path):
Line 100  class OSAS_StoreOnline(SimpleItem): Line 104  class OSAS_StoreOnline(SimpleItem):
             return []              return []
   
     def rescaleThumbs(self,path):      def rescaleThumbs(self,path):
         """rescale thumbs of imeages in 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 >> /tmp/sc.out &"% re.sub('/mpiwg/online/','',self.REQUEST['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']          self.REQUEST.SESSION['path']=self.REQUEST['path']
         #return self.REQUEST.RESPONSE.redirect(self.REQUEST['URL1'])          #return self.REQUEST.RESPONSE.redirect(self.REQUEST['URL1'])
         pt=PageTemplateFile('Products/OSA_system/OSAS_scaled.zpt').__of__(self)          pt=PageTemplateFile('Products/OSA_system/zpt/OSAS_scaled.zpt').__of__(self)
         return pt()          return pt()
   
           
Line 148  class OSAS_StoreOnline(SimpleItem): Line 152  class OSAS_StoreOnline(SimpleItem):
         return isFolder(self,path)          return isFolder(self,path)
           
     def isScannedDocument(self,path):      def isScannedDocument(self,path):
         """Test ob Eintrag ein Folder ist"""          """Test ob Eintrag ein Scanned Document ist"""
         return isScannedDocument(self,path)          return isScannedDocument(self,path)
   
     def isFullText(self,path,folder_name):      def isFullText(self,path,folder_name):
         """Test ob Eintrag ein Folder ist"""          """Test ob Eintrag ein Folder ist"""
         return isFullText(path,folder_name)          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):      def addFolderForm(self,path):
         """add a new path"""          """add a new path"""
         pt=PageTemplateFile('Products/OSA_system/OSAS_addFolder.zpt').__of__(self)          pt=PageTemplateFile('Products/OSA_system/zpt/OSAS_addFolder.zpt').__of__(self)
         return pt()          return pt()
   
     def date(self):      def showHelp(self,refType,genericTag):
     return strftime("%d.%m.%Y",localtime())           """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):      def addFolder(self,path,folder_name,description,archive_creation_date,creator):
         """add the folder to the filesystem and write the metadata files"""          """add the folder to the filesystem and write the metadata files"""
Line 174  class OSAS_StoreOnline(SimpleItem): Line 196  class OSAS_StoreOnline(SimpleItem):
             indexmeta=dom.toxml()              indexmeta=dom.toxml()
         except:          except:
             indexmeta=""              indexmeta=""
               
         self.REQUEST.SESSION['indexmeta']=indexmeta          self.REQUEST.SESSION['indexmeta']=indexmeta
         self.REQUEST.SESSION['path']=path          self.REQUEST.SESSION['path']=path
         newtemplate=PageTemplateFile('Products/OSA_system/editindex').__of__(self)          newtemplate=PageTemplateFile('Products/OSA_system/zpt/editindex').__of__(self)
         return newtemplate()          return newtemplate()
   
     def EditIndex2(self):      def EditIndex2(self):
Line 197  class OSAS_StoreOnline(SimpleItem): Line 220  class OSAS_StoreOnline(SimpleItem):
               
     def add_metafile(self):      def add_metafile(self):
         """nothing"""          """nothing"""
         pt=PageTemplateFile('Products/OSA_system/OSAS_addmetadata.zpt').__of__(self)          pt=PageTemplateFile('Products/OSA_system/zpt/OSAS_addmetadata.zpt').__of__(self)
         return pt()          return pt()
   
       def getTextToolsField(self,path,name,default=''):
           """Lese Textoolsfelder aus index.meta im path aus"""
           
           try:
               dom=xml.dom.minidom.parse(path+"/index.meta")
               node=dom.getElementsByTagName('texttool')[0] #getNode
               subnode=node.getElementsByTagName(name)[0]
               
               return getText(subnode.childNodes)
           except:
               return default
               
       def getProjects(self,obj_ids=None):
           """Get the Project title for configuration"""
           ret=[]
           
           try:
               projects=self.ZopeFind(self.projects,obj_metatypes=['OSAS_project'],obj_ids=obj_ids)#assumes projects folder somewhere in the hierarchie.
               
               for project in projects:
                   ret.append((project[1].title,project[0],project[1]))
               
               return ret
           
           except:
               return [('no Projectfolders','')]
   
       def changeTemplatesForm(self,path):
           """changeform"""
           path=self.REQUEST.SESSION['path']=path
           pt=PageTemplateFile('Products/OSA_system/zpt/changeTemplatesForm.zpt').__of__(self)
           return pt()
   
           
   
       def changeTemplates(self,path):
           """Andere alle Eintraege in index.meta"""
           #os.path.walk(path,OSAS_helpers.changeIndexMeta,startpage,xslt,thumbtemplate,topbar,digiLibTemplate)
           print self.REQUEST.form
   
   
           os.path.walk(path,OSAS_helpers.changeIndexMeta,self.REQUEST.form)
           
           
 InitializeClass(OSAS_StoreOnline)  InitializeClass(OSAS_StoreOnline)
           
 def manage_AddOSAS_StoreOnlineForm(self):  def manage_AddOSAS_StoreOnlineForm(self):
     """interface for adding the OSAS_root"""      """interface for adding the OSAS_root"""
     pt=PageTemplateFile('Products/OSA_system/AddOSAS_StoreOnline.zpt').__of__(self)      pt=PageTemplateFile('Products/OSA_system/zpt/AddOSAS_StoreOnline.zpt').__of__(self)
     return pt()      return pt()
   
 def manage_AddOSAS_StoreOnline(self,id,RESPONSE=None):  def manage_AddOSAS_StoreOnline(self,id,RESPONSE=None):
Line 246  from AccessControl import ClassSecurityI Line 313  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 377  class filesystem(Implicit, Persistent, R Line 448  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 385  class filesystem(Implicit, Persistent, R Line 457  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 477  class filesystem2(Implicit, Persistent, Line 550  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 612  class browse(Implicit, Persistent, RoleM Line 686  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 882  def getBib(nodelist): Line 958  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 891  def getMetafile(path): Line 967  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 928  def hasMetafile(path): Line 1019  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 1137  def isScannedDocument(self,path): Line 1230  def isScannedDocument(self,path):
             try:              try:
                   dom = xml.dom.minidom.parseString(lines)                    dom = xml.dom.minidom.parseString(lines)
                   content_type=getText(dom.getElementsByTagName("content-type")[0].childNodes)                     content_type=getText(dom.getElementsByTagName("content-type")[0].childNodes) 
                   if (content_type=="scanned-document") or (content_type=="scanned document"):                    if (content_type=="scanned-document") or (content_type=="scanned document") or (content_type=="fulltext document"):
                         return 1                          return 1
                   else:                    else:
                         return 0                          return 0

Removed from v.1.10  
changed lines
  Added in v.1.20


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