Diff for /ImageArchive/ImageArchive.py between versions 1.59 and 1.61

version 1.59, 2005/05/03 16:31:36 version 1.61, 2005/07/04 11:01:02
Line 4  from Globals import Persistent,package_h Line 4  from Globals import Persistent,package_h
 from Acquisition import Implicit  from Acquisition import Implicit
 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 xmlrpclib import ServerProxy
 import re  import re
 import os  import os
 import os.path  import os.path
Line 16  from types import * Line 17  from types import *
 import time  import time
 from threading import Thread  from threading import Thread
 import Queue  import Queue
   import cgi
   
   try:
       from Products.ZSQLExtend.ZSQLExtend import ZSQLExtendFolder
   except:
       print "ZSQL Extend Folder nicht importiert"
       print "Metadatendfolder funktioniert nicht!!!"
   
 try:  try:
     from Products.ECHO_content.ECHO_collection import ECHO_basis      from Products.ECHO_content.ECHO_collection import ECHO_basis
Line 111  class generateSet: Line 119  class generateSet:
                                 self.response+=(str("<p>Error in File: %s (possible missing)<br>\n"%filename))                                  self.response+=(str("<p>Error in File: %s (possible missing)<br>\n"%filename))
             else:              else:
                 if self.version=="working":                  if self.version=="working":
                     path="http://nausikaa2.rz-berlin.mpg.de/digitallibrary/servlet/Scaler/?fn="+self.ImageViewerPath+"/"+os.path.splitext(urllib.quote(id[0]))[0]+"&dh=2000&dw=2000"                      path=self.scalerPath+self.ImageViewerPath+"/"+os.path.splitext(urllib.quote(id[0]))[0]+"&dh=2000&dw=2000"
                 else:                  else:
                     path="http://nausikaa2.rz-berlin.mpg.de/digitallibrary/servlet/Scaler/?fn="+self.ImageViewerPath+"/"+os.path.splitext(urllib.quote(id[0]))[0]+"&mo=rawfile,hires"                      path=self.scalerPath+self.ImageViewerPath+"/"+os.path.splitext(urllib.quote(id[0]))[0]+"&mo=rawfile,hires"
                 image=urllib.urlopen(path).read()                  image=urllib.urlopen(path).read()
                           
                           
Line 155  class generateSet: Line 163  class generateSet:
                                                 self.response+=str("<p>Error in File: %s (missing?)<br>\n"%filename)                                                  self.response+=str("<p>Error in File: %s (missing?)<br>\n"%filename)
                                                       
                     else:                      else:
                         path="http://nausikaa2.rz-berlin.mpg.de/digitallibrary/servlet/Scaler/?fn="+self.ImageViewerPath+"/"+os.path.splitext(ids[nr+i])[0]+"&mo=rawfile,hires"                          path=self.scalerPath+self.ImageViewerPath+"/"+os.path.splitext(ids[nr+i])[0]+"&mo=rawfile,hires"
   
                         image=urllib.urlopen(path).read()                          image=urllib.urlopen(path).read()
                                           
Line 238  class metaData(SimpleItem): Line 246  class metaData(SimpleItem):
         return ret+"</body></html>"          return ret+"</body></html>"
                                   
                   
   
       
 class ImageDigilib(Folder,Persistent,Implicit):  class ImageDigilib(Folder,Persistent,Implicit):
     """Anzeige object fuer digilib"""      """Anzeige object fuer digilib"""
     meta_type="ImageDigilib"      meta_type="ImageDigilib"
Line 332  class ImageDigilib(Folder,Persistent,Imp Line 342  class ImageDigilib(Folder,Persistent,Imp
           
     def download(self,fmt="&mo=rawfile,hires",suffix=None):      def download(self,fmt="&mo=rawfile,hires",suffix=None):
         """download"""          """download"""
         path="http://nausikaa2.rz-berlin.mpg.de/digitallibrary/servlet/Scaler/?fn="+self.ImageViewerPath+"/"+os.path.splitext(self.filename)[0]+fmt          path=self.scalerPath+self.ImageViewerPath+"/"+os.path.splitext(self.filename)[0]+fmt
           
     if self.REQUEST.SESSION.has_key('filenamesIds') and self.REQUEST.SESSION['filenamesIds'].has_key(self.filename):      if self.REQUEST.SESSION.has_key('filenamesIds') and self.REQUEST.SESSION['filenamesIds'].has_key(self.filename):
         filename=self.REQUEST.SESSION['filenamesIds'][self.filename][0]+"_"+self.filename          filename=self.REQUEST.SESSION['filenamesIds'][self.filename][0]+"_"+self.filename
Line 463  class ImageDigilib(Folder,Persistent,Imp Line 473  class ImageDigilib(Folder,Persistent,Imp
     def thumb(self,url=None):      def thumb(self,url=None):
         """show thumb"""          """show thumb"""
         thumbname=os.path.splitext(self.filename)[0]+".jpg"          thumbname=os.path.splitext(self.filename)[0]+".jpg"
         ## if not os.path.exists("/mpiwg/temp/online/scaled/small/"+self.ImageViewerPath+"/"+thumbname):  
 ##             image=urllib.urlopen("http://nausikaa2.rz-berlin.mpg.de:18080/digitallibrary/servlet/Scaler/?fn="+self.ImageViewerPath+"/"+self.filename+"&dw=150&mo=lores").read()  
 ##             f=open("/mpiwg/temp/online/scaled/small/"+self.ImageViewerPath+"/"+thumbname,"w")  
 ##             f.write(image)  
 ##             f.close()  
 ##             os.popen("ssh nausikaa2.rz-berlin.mpg.de /usr/local/mpiwg/scripts/scaleomat.pl %s /mpiwg/temp/online/scaled/small 150 &"% self.ImageViewerPath)  
                           
         #DEVEL:take nausikaa for server solution          path=self.scalerPath+self.ImageViewerPath+"/"+os.path.splitext(self.filename)[0]+"&dw=100&dh=100&mo=lores"
                   
         path="http://nausikaa2.rz-berlin.mpg.de/digitallibrary/servlet/Scaler/?fn="+self.ImageViewerPath+"/"+os.path.splitext(self.filename)[0]+"&dw=100&dh=100&mo=lores"  
         #path="/mpiwg/online/"+self.ImageViewerPath+"/"+thumbname  
         self.REQUEST.SESSION['string']="<img border=\"0\" src=\"%s\">"% path          self.REQUEST.SESSION['string']="<img border=\"0\" src=\"%s\">"% path
         if url:          if url:
             return "<img border=\"0\" src=\"%s\">"% path              return "<img border=\"0\" src=\"%s\">"% path
Line 481  class ImageDigilib(Folder,Persistent,Imp Line 483  class ImageDigilib(Folder,Persistent,Imp
             pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','thumb.zpt')).__of__(self)              pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','thumb.zpt')).__of__(self)
             return pt()              return pt()
           
   
       def thumbMD(self,url=None):
           """show thumb mit Metadaten erwarten image in ImageCollectionMD
           """
           thumbname=os.path.splitext(self.filename)[0]+".jpg"
       
           path=self.scalerPath+self.ImageViewerPath+"/"+os.path.splitext(self.filename)[0]+"&dw=100&dh=100&mo=lores"
       
           self.REQUEST.SESSION['string']="<img border=\"0\" src=\"%s\">"% path
           if url:
               return "<img border=\"0\" src=\"%s\">"% path
           else:
               
               overview=self.ZopeFind(self.aq_parent,obj_ids=['thumb.html'])
               if overview:
                   return getattr(self,overview[0][0])()
               else:
                   pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','thumbMD.zpt')).__of__(self)
                   return pt()
   
   
   
     def index_html(self):      def index_html(self):
         """show image"""          """show image"""
         #DEVELOP: take first one for server          #DEVELOP: take first one for server
                   #path="http://127.0.0.1:8080/zogilib_images?lv=2&fn="+self.ImageViewerPath+"/"+os.path.splitext(self.filename)[0]
         path="http://content.mpiwg-berlin.mpg.de/zogilib_images?lv=2&fn="+self.ImageViewerPath+"/"+os.path.splitext(self.filename)[0]          path="http://content.mpiwg-berlin.mpg.de/zogilib_images?lv=2&fn="+self.ImageViewerPath+"/"+os.path.splitext(self.filename)[0]
         return self.REQUEST.RESPONSE.redirect(path)          return self.REQUEST.RESPONSE.redirect(path)
   
Line 514  class ImageCollection(Folder, Persistent Line 538  class ImageCollection(Folder, Persistent
     """Sammelordner für Bilder"""      """Sammelordner für Bilder"""
     meta_type="ImageCollection"      meta_type="ImageCollection"
   
       #scalerPath="http://127.0.0.1:18080/digitallibrary/servlet/Scaler/?fn="
       scalerPath="http://nausikaa2.rz-berlin.mpg.de/digitallibrary/servlet/Scaler/?fn="
         
     zipThreads={}      zipThreads={}
     zipThreads2={}      zipThreads2={}
Line 525  class ImageCollection(Folder, Persistent Line 551  class ImageCollection(Folder, Persistent
           
     defaultMetaString="http://fm-web.mpiwg-berlin.mpg.de:8050/FMRes/FMPJS?-db=Wissenschaftlerportraits.fp5&-layID=69&-token=25&-max=1&-format=formvwcss.htm&-mode=browse&images::filename=%s&-find" ## TEST FUER IMAGEDATENBANK WP      defaultMetaString="http://fm-web.mpiwg-berlin.mpg.de:8050/FMRes/FMPJS?-db=Wissenschaftlerportraits.fp5&-layID=69&-token=25&-max=1&-format=formvwcss.htm&-mode=browse&images::filename=%s&-find" ## TEST FUER IMAGEDATENBANK WP
   
       def getScalerPath(self):
           """get ScalerPath"""
           return self.scalerPath
       
       def getImageViewerPath(self):
           """get ImageViewerPath"""
           return self.ImageViewerPath
   
       def getImageStoragePath(self):
           """get ImageStoragePath"""
           return self.ImageStoragePath
         
     def refreshTxt(self):      def refreshTxt(self):
         """txt fuer refresh"""          """txt fuer refresh"""
Line 886  class ImageCollection(Folder, Persistent Line 923  class ImageCollection(Folder, Persistent
   
         RESPONSE.redirect('manage_main')          RESPONSE.redirect('manage_main')
   
     def importStructure(self,path):      ## def importStructure(self,path):
         """import"""  ##         """import"""
         splitted=os.path.split(path)  ##         splitted=os.path.split(path)
         if os.path.isDir(path) and (len(splitted[1])>0) and (splitted[1][0]=="."):  ##         if os.path.isDir(path) and (len(splitted[1])>0) and (splitted[1][0]=="."):
             manage_AddImageCollection(self,splitted[1],splitted[1],path,self.ImageViewerPath,self.defaultMetaString,RESPONSE=None)  ##             manage_AddImageCollection(self,splitted[1],splitted[1],path,self.ImageViewerPath,self.defaultMetaString,RESPONSE=None)
                           
             obj=getattr(self,splitted[1])  ##             obj=getattr(self,splitted[1])
             obj.ImportFiles()  ##             obj.ImportFiles()
   
     def ImportStructure(self,RESPONSE=None):      def ImportStructure(self,RESPONSE=None):
         """Import the existing files of a folder"""          """Import the existing files of a folder"""
Line 1385  class ImageCollection(Folder, Persistent Line 1422  class ImageCollection(Folder, Persistent
             return fn              return fn
     def index_html(self,fn=None):      def index_html(self,fn=None):
         """main template collection"""          """main template collection"""
         print      
         if fn:          if fn:
             ret=[]              ret=[]
   
Line 1417  class ImageCollection(Folder, Persistent Line 1454  class ImageCollection(Folder, Persistent
             self.REQUEST.SESSION['showall']=self.REQUEST.SESSION.get('showall','no')              self.REQUEST.SESSION['showall']=self.REQUEST.SESSION.get('showall','no')
                           
             
           overview=self.ZopeFind(self,obj_ids=['overview.html'])
           if overview:
               return overview[0][1]()
           else:
         pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','overview.zpt')).__of__(self)          pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','overview.zpt')).__of__(self)
         return pt()          return pt()
           
Line 1434  def manage_AddImageCollection(self,id,ti Line 1475  def manage_AddImageCollection(self,id,ti
         RESPONSE.redirect('manage_main')          RESPONSE.redirect('manage_main')
   
   
   
   class ImageCollectionMD(ImageCollection,ZSQLExtendFolder):
       """Imageviewer and Metadata"""
       meta_type="ImageCollection MD"
       #scalerPath="http://127.0.0.1:18080/digitallibrary/servlet/Scaler/?fn="
       scalerPath="http://nausikaa2.rz-berlin.mpg.de/digitallibrary/servlet/Scaler/?fn="
       manage_options=ImageCollection.manage_options+(
           {'label':'ZSQLExtend','action':'changeZSQLExtendForm'},
          )
   
       changeZSQLExtendForm=ZSQLExtendFolder.changeZSQLExtendForm
       
       def setGenericSearchStringForm(self):
           """form setze generischen search string fuer MD"""
           pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','setGenericSearchStringForm.zpt')).__of__(self)
           return pt()
   
       def setGenericSearchString(self,searchString):
           """setze generischen search string"""
           self.searchString=searchString
   
       def thumblistMD(self):
           """main template collection"""
           pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','thumbListMD.zpt')).__of__(self)
           return pt()
   
   
   def manage_AddImageCollectionMDForm(self):
       """Nothing yet"""
       pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','AddImageCollectionFormMD.zpt')).__of__(self)
       return pt()
       
   def manage_AddImageCollectionMD(self,id,title,ImageStoragePath,ImageViewerPath,defaultMetaString,RESPONSE=None):
       """Add ImageCollection"""
       newObj=ImageCollectionMD(id,title,ImageStoragePath,ImageViewerPath,defaultMetaString)
       self._setObject(id,newObj)
       
       if RESPONSE is not None:
           RESPONSE.redirect('manage_main')
   
   
   
           
 class ImageCollectionIFrame(ImageCollection):  class ImageCollectionIFrame(ImageCollection):
     """Class fuer Collection set als IFrame"""      """Class fuer Collection set als IFrame"""
   
Line 1490  def manage_AddImageCollectionIFrame(self Line 1574  def manage_AddImageCollectionIFrame(self
         RESPONSE.redirect('manage_main')          RESPONSE.redirect('manage_main')
   
   
   class ImageZogiLib(ImageDigilib):
       """Anzeige Object fuer Bilder ausserhalb von collections
       ImageViewerPath und ImageStoragePath und wenn vorhanden Pfad zur Collection
       werden zusaetzlich abgespeichert
       """
   
       meta_type="ImageZogiLib"
   
       manage_options=ImageDigilib.manage_options+(
            {'label':'Main Config','action':'changeImageZogiLibForm'},        
           )
   
       def __init__(self,id,fn,ImageViewerPath,ImageStoragePath,scalerPath,ImageCollectionPath=None,REQUEST=None):
           ImageDigilib.__init__(self,id,fn)
           self.ImageViewerPath=ImageViewerPath
           self.ImageStoragePath=ImageStoragePath
           self.ImageCollectionPath=ImageCollectionPath
           self.scalerPath=scalerPath
   
       def changeImageZogiLibForm(self):
           """change zogilib Form"""
           pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','changeImageZogiLib.zpt')).__of__(self)
           return pt()        
   
   
       def changeImageZogilib(fn,ImageViewerPath,ImageStoragePath,scalerPath,ImageCollectionPath,REQUEST=None):
           """Change it"""
           self.ImageViewerPath=ImageViewerPath
           self.ImageStoragePath=ImageStoragePath
           self.ImageCollectionPath=ImageColectionPath
           self.scalerPath=scalerPath
       
   def manage_AddImageZogiLib(self,id=None,ImageViewerPath=None,ImageStoragePath=None,fileUpload=None,ImageCollectionPath=None,scalerPath=None,libPath=None,caption=None,RESPONSE=None):
       """hinzufuegen eineis zogilibImage"""
   
       if libPath:
           splitted=libPath.split("?")
           urlSplit=splitted[0].split("/")
           params=cgi.parse_qs(splitted[1])
           #is LibPath a digilib path?
           if urlSplit[-1]=="Scaler":
               if type(params['fn']) is ListType:
                   fnParam=params['fn'][0]
               else:
                   fnParam=params['fn']
               fileNameSplit=os.path.split(fnParam)
               ImageViewerPath=fileNameSplit[0]
               id=fileNameSplit[1]
               scalerPath=splitted[0]+"?fn="
           else: #assume if not the path is a path to an ImageCollection
               if type(params['filename']) is ListType:
                   id=params['filename'][0]
               else:
                   id=params['filename']
   
               server=ServerProxy(splitted[0])
               ImageCollectionPath=libPath
               ImageViewerPath=server.getImageViewerPath()
               ImageStoragePath=server.getImageStoragePath()
               scalerPath=server.getScalerPath()
           
   
   
       if fileUpload:
           fn=splitPath(fileUpload.filename)
       else:
           fn=id
           
       newObj=ImageZogiLib(id,fn,ImageViewerPath,ImageStoragePath,scalerPath,ImageCollectionPath)
       
       self._setObject(id,newObj)
       getattr(self,id).caption=caption[0:]
       if fileUpload:
           getattr(self,id).uploadImage(fileupload,self.ImageStoragePath)
       
       if RESPONSE is not None:
           RESPONSE.redirect('manage_main')
   
                    
   def manage_AddImageZogiLibForm(self):
       """to be done"""
       

Removed from v.1.59  
changed lines
  Added in v.1.61


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