Diff for /ImageArchive/ImageArchive.py between versions 1.87 and 1.93

version 1.87, 2006/05/17 20:37:29 version 1.93, 2006/05/24 09:56:58
Line 25  import Queue Line 25  import Queue
 import cgi  import cgi
 import sys  import sys
 import zLOG  import zLOG
   import shutil
   
 from AccessControl import ClassSecurityInfo, getSecurityManager  from AccessControl import ClassSecurityInfo, getSecurityManager
   
Line 286  class ImageDigilib(Folder,Persistent,Imp Line 286  class ImageDigilib(Folder,Persistent,Imp
                   
         )          )
   
   
           
     def getAccessRight(self):      def getAccessRight(self):
         """get the accessright, return is string "extern" or "intern" """          """get the accessright, return is string "extern" or "intern" """
         return self.getRights(self.filename.split('.')[0])          return self.getRights(self.filename.split('.')[0])
Line 388  class ImageDigilib(Folder,Persistent,Imp Line 390  class ImageDigilib(Folder,Persistent,Imp
             os.chmod(filename,0664)              os.chmod(filename,0664)
         except:          except:
             """hack"""              """hack"""
         #scale thumb          #< thumb
                   
         #self.scaleThumbs()          self.scaleThumbs()
   
         #scale standard          #scale standard
   
         #self.scaleWorkingVersions()          self.scaleWorkingVersions()
   
                   
                   
Line 448  class ImageDigilib(Folder,Persistent,Imp Line 450  class ImageDigilib(Folder,Persistent,Imp
             self.title=newname[0:]              self.title=newname[0:]
             self.filename=newname[0:]                 self.filename=newname[0:]   
             #umbennen des files auf dem server              #umbennen des files auf dem server
             oldpath=os.path.join(self.ImageStoragePath,oldname)              oldpath=os.path.join(self.getImageStoragePath(),oldname)
             newpath=os.path.join(self.ImageStoragePath,newname)              newpath=os.path.join(self.getImageStoragePath(),newname)
             os.rename(oldpath,newpath)              os.rename(oldpath,newpath)
                           
             #umbenennen des versionsfolders              #umbenennen des versionsfolders
             oldfolder=os.path.join(self.ImageStoragePath,"."+oldname+".dir")              oldfolder=os.path.join(self.getImageStoragePath(),"."+oldname+".dir")
             newfolder=os.path.join(self.ImageStoragePath,"."+newname+".dir")              newfolder=os.path.join(self.getImageStoragePath(),"."+newname+".dir")
             if os.path.exists(oldfolder):              if os.path.exists(oldfolder):
                 os.rename(oldfolder,newfolder)                  os.rename(oldfolder,newfolder)
             else:              else:
Line 480  class ImageDigilib(Folder,Persistent,Imp Line 482  class ImageDigilib(Folder,Persistent,Imp
                           
             #scale thumb              #scale thumb
                   
             #self.scaleThumbs()              self.scaleThumbs()
                           
             #scale standard              #scale standard
   
             #self.scaleWorkingVersions()              self.scaleWorkingVersions()
   
   
               self.scaleToJpg()
             if RESPONSE:              if RESPONSE:
                     RESPONSE.redirect(self.aq_parent.absolute_url()+"?filename="+self.filename)                      RESPONSE.redirect(self.aq_parent.absolute_url()+"?filename="+self.filename)
                   
       def scaleToJpg(self,RESPONSE=None):
           """create a  jpg"""
           
           #create backup of the original file
           
           imagePath=os.path.join(self.getImageStoragePath(),self.filename)
           path=os.path.join(self.getImageStoragePath(),"."+self.getId()+".dir")
                   
           if not os.path.exists(path):
               os.mkdir(path,0775)
               os.chmod(path,0775)
               
           newName=os.path.join(path,self.getId())
   
           if os.path.exists(newName):
               zLOG.LOG("ImageArchive:scaleToJpg", zLOG.INFO, "%s already exists"%newName)
           else:
               try:
                   os.rename(imagePath,newName)
               except:
                   zLOG.LOG("ImageArchive:scaleToJpg", zLOG.ERROR, "%s "%newName)
                   return False
               
           ext= os.path.splitext(imagePath)[1].lower()
           if ext.rstrip()==".jpg":
                   shutil.copy(newName,imagePath)
                   print "copy",imagePath
                   return True
   
   
   
           dir=self.getId()
           src=path
           self.scale(dest=self.getImageStoragePath(),dir=dir,src=path,scaleBy=1,RESPONSE=RESPONSE)
           return True
   
     def updateImage(self,_fileupload,_rename=None,RESPONSE=None):      def updateImage(self,_fileupload,_rename=None,RESPONSE=None):
         """lade neues Version des Bildes"""          """lade neues Version des Bildes"""
         #teste ob Dokumenten ordner schon vorhanden          #teste ob Dokumenten ordner schon vorhanden
         #imagePath=os.path.join(self.ImageStoragePath,self.getId())          #imagePath=os.path.join(self.getImageStoragePath(),self.getId())
                   
         identifyField="filename"          identifyField="filename"
                   
         if _fileupload and _fileupload.filename!="":          if _fileupload and _fileupload.filename!="":
             imagePath=os.path.join(self.ImageStoragePath,self.filename)              imagePath=os.path.join(self.getImageStoragePath(),self.filename)
             path=os.path.join(self.ImageStoragePath,"."+self.getId()+".dir")              path=os.path.join(self.getImageStoragePath(),"."+self.getId()+".dir")
                                   
             if not os.path.exists(path):              if not os.path.exists(path):
                 os.mkdir(path,0775)                  os.mkdir(path,0775)
Line 522  class ImageDigilib(Folder,Persistent,Imp Line 559  class ImageDigilib(Folder,Persistent,Imp
                 zLOG.LOG("ImageArchive:updateImage", zLOG.ERROR, "rename: %s -> %s didn't work!"%(imagePath,imageNewPath))                    zLOG.LOG("ImageArchive:updateImage", zLOG.ERROR, "rename: %s -> %s didn't work!"%(imagePath,imageNewPath))  
           
             #lesen des upload files und schreiben              #lesen des upload files und schreiben
             filedata=file.read()              filedata=_fileupload.read()
             f=open(imagePath,"w") # if we wanted to have filename=id we should do it here!              f=open(imagePath,"w") # if we wanted to have filename=id we should do it here!
             f.write(filedata)              f.write(filedata)
             f.close()              f.close()
Line 532  class ImageDigilib(Folder,Persistent,Imp Line 569  class ImageDigilib(Folder,Persistent,Imp
                 pass                  pass
             #scale thumb              #scale thumb
                           
             #self.scaleThumbs()              self.scaleThumbs()
                                   
             #scale standard              #scale standard
           
             #self.scaleWorkingVersions()              self.scaleWorkingVersions()
                   self.scaleToJpg()
             if _rename:              if _rename:
                 self.renameImage(file.filename)                  self.renameImage(_fileupload.filename)
                   
             
         args=self.REQUEST.form          args=self.REQUEST.form
Line 633  def manage_AddImageDigilib(self,id,fileu Line 670  def manage_AddImageDigilib(self,id,fileu
     newObj=ImageDigilib(id,fn,meta)      newObj=ImageDigilib(id,fn,meta)
           
     self._setObject(id,newObj)      self._setObject(id,newObj)
     getattr(self,id).uploadImage(fileupload,self.ImageStoragePath)      getattr(self,id).uploadImage(fileupload,self.getImageStoragePath())
           
     if RESPONSE is not None:      if RESPONSE is not None:
         RESPONSE.redirect('manage_main')          RESPONSE.redirect('manage_main')
Line 665  class ImageCollection(OrderedFolder, Per Line 702  class ImageCollection(OrderedFolder, Per
     imgcoll_thumb = PageTemplateFile('zpt/thumb', globals())      imgcoll_thumb = PageTemplateFile('zpt/thumb', globals())
     imgcoll_thumbMD = PageTemplateFile('zpt/thumbMD', globals())          imgcoll_thumbMD = PageTemplateFile('zpt/thumbMD', globals())    
   
       destBasis="/docuserver/scaled/"
       scaledBasis=destBasis
       srcBasis="/docuserver/images"
       scaleomatStr="/docuserver/libs/scaleomat/scaleomat.pl"
       
       #dest="/Volumes/paviaExtern/docuserver/images/exhibitionImages/"
       
       def configScaleForm(self):
           """configure the scaler form"""
           pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','configScale.zpt')).__of__(self)
           return pt()        
   
       def configScale(self,scaleomatStr,RESPONSE=None):
           """config the scaler"""
           self.scaleomatStr=scaleomatStr
           
               
           if RESPONSE is not None:
               RESPONSE.redirect('manage_main')
   
       def scale(self,dest=None,dir=None,src=None,scaleTo=None,scaleBy=None,RESPONSE=None):
           """scaler"""
           #scaleomatStr="ssh nausikaa2.rz-berlin.mpg.de /usr/local/mpiwg/scripts/scaleomat.pl -src=/mpiwg/online/ %s"
           scaleomatStr=self.scaleomatStr
   
           destBasis=self.destBasis
           srcBasis=self.srcBasis
           
           
           if src:
                srcStr=" -src=%s"%src
           else:
                srcStr=" -src=%s"%srcBasis
   
           scaleStr=scaleomatStr+srcStr
           if dir:
               dirTmp=dir.replace(srcBasis,'')
               dirStr=" -dir=%s"%dirTmp
               scaleStr=scaleStr+dirStr
           elif filename:
               fileTmp=filename.replace(srcBasis,'')
               fileStr=" -dir=%s"%fileTmp
               scaleStr=scaleStr+fileStr
           else:
               zLOG.LOG("ImageCollection:scale",zLOG.ERROR,"no directory or filename given")
               return False
           
           if dest is not None:
               destStr=" -dest=%s"%os.path.join(destBasis,dest)
               scaleStr=scaleStr+destStr
           else:
               zLOG.LOG("ImageCollection:scale",zLOG.ERROR,"no destionation given")
               return False
           
           if scaleTo:
               scaleToStr=" -scaleto=%s"%scaleTo
               scaleStr=scaleStr+scaleToStr
           elif scaleBy:
               scaleByStr=" -scaleby=%s"%scaleBy
               scaleStr=scaleStr+scaleByStr
           else:
               zLOG.LOG("ImageCollection:scale",zLOG.ERROR,"no destionation given")
               return False
        
          
           #ret=scaleStr
           ret=os.popen2(scaleStr,1)[1].read()
    
           if RESPONSE:
                RESPONSE.write(ret)
           return True
    
     def getImageObject(self,name):      def getImageObject(self,name):
         """gibt objeckt name zurueck"""          """gibt objeckt name zurueck"""
         if hasattr(self,name):          if hasattr(self,name):
Line 697  class ImageCollection(OrderedFolder, Per Line 806  class ImageCollection(OrderedFolder, Per
   
     def getImageStoragePath(self):      def getImageStoragePath(self):
         """get ImageStoragePath"""          """get ImageStoragePath"""
         return self.ImageStoragePath          if self.ImageViewerPath[0]=="/":
               if len(self.ImageViewerPath)>1:
                   iv=self.ImageViewerPath[1:]
               else:
                   iv=""
           else:
                   iv=self.ImageViewerPath
   
           return os.path.join(self.srcBasis,iv)
           
     def refreshTxt(self):      def refreshTxt(self):
         """txt fuer refresh"""          """txt fuer refresh"""
Line 784  class ImageCollection(OrderedFolder, Per Line 901  class ImageCollection(OrderedFolder, Per
             self.REQUEST.RESPONSE.close()              self.REQUEST.RESPONSE.close()
   
                                           
       def scaleToJpgs(self,RESPONSE=None):
           """scale all tifs to jps"""
   
           for x in self._objects:
                   
                   if (not hasattr(getattr(self,x['id']),'scaleToJpg')) or (not getattr(self,x['id']).scaleToJpg()):
                       if RESPONSE:
                           RESPONSE.write('error:%s'%x)
                   
                   
                                           
     def scaleThumbs(self,RESPONSE=None):      def scaleThumbs(self,RESPONSE=None):
         """scale thumbs"""          """scale thumbs"""
                   
         #scale thumbs          #scale thumbs
         ret=os.popen("ssh nausikaa2.rz-berlin.mpg.de /usr/local/mpiwg/scripts/scaleomat.pl -src=/mpiwg/online/ -dir=%s -dest=/mpiwg/temp/online/scaled/thumb -scaleto=100 &"% self.ImageViewerPath)          dest=os.path.join(self.scaledBasis,'thumb')
           self.scale(dir=self.getImageStoragePath(),dest=dest,scaleTo=100,RESPONSE=RESPONSE)
           #ret=os.popen("ssh nausikaa2.rz-berlin.mpg.de /usr/local/mpiwg/scripts/scaleomat.pl -src=/mpiwg/online/ -dir=%s -dest=/mpiwg/temp/online/scaled/thumb -scaleto=100 &"% self.ImageViewerPath)
         if RESPONSE:          if RESPONSE:
                 RESPONSE.write(ret.read())                  RESPONSE.write(ret.read())
                 RESPONSE.write("\n")                  RESPONSE.write("\n")
Line 801  class ImageCollection(OrderedFolder, Per Line 930  class ImageCollection(OrderedFolder, Per
                   
         #scale standard          #scale standard
   
         ret=os.popen("ssh nausikaa2.rz-berlin.mpg.de /usr/local/mpiwg/scripts/scaleomat.pl -src=/mpiwg/online/ -dir=%s -dest=/mpiwg/temp/online/scaled/small -scaleto=2000 &"% self.ImageViewerPath)          dest=os.path.join(self.scaledBasis,'small')
           self.scale(dir=self.getImageStoragePath(),dest=dest,scaleTo=1000,RESPONSE=RESPONSE)
           
           dest=os.path.join(self.scaledBasis,'medium')
           self.scale(dir=self.getImageStoragePath(),dest=dest,scaleTo=2000,RESPONSE=RESPONSE)
          
           #ret=os.popen("ssh nausikaa2.rz-berlin.mpg.de /usr/local/mpiwg/scripts/scaleomat.pl -src=/mpiwg/online/ -dir=%s -dest=/mpiwg/temp/online/scaled/small -scaleto=2000 &"% self.ImageViewerPath)
         if RESPONSE:          if RESPONSE:
                 RESPONSE.write(ret.read())                  RESPONSE.write(ret.read())
                 RESPONSE.write("\n")                  RESPONSE.write("\n")
         return "rescaling started"          return "rescaling started"
   
   
           def __init__(self,id,title,ImageViewerPath,defaultMetaString,destBasis,srcBasis,serverPath=genericServerPath):
     def __init__(self,id,title,ImageStoragePath,ImageViewerPath,defaultMetaString,serverPath=genericServerPath):  
         self.id=id          self.id=id
         self.title=title          self.title=title
         self.ImageStoragePath=ImageStoragePath  
         self.ImageViewerPath=ImageViewerPath          self.ImageViewerPath=ImageViewerPath
         self.defaultMetaString=defaultMetaString          self.defaultMetaString=defaultMetaString
         self.serverPath=serverPath          self.serverPath=serverPath
           self.destBasis=destBasis
           self.srcBasis=srcBasis
         self.defaultrows = 6          self.defaultrows = 6
         self.defaultcols = 2          self.defaultcols = 2
   
Line 823  class ImageCollection(OrderedFolder, Per Line 958  class ImageCollection(OrderedFolder, Per
   
     manage_options = optTMP+(      manage_options = optTMP+(
         {'label':'Main Config','action':'ImageCollection_config'},          {'label':'Main Config','action':'ImageCollection_config'},
           {'label':'Config Scaler','action':'configScaleForm'},
         {'label':'Import','action':'ImportFiles'},          {'label':'Import','action':'ImportFiles'},
         {'label':'Recalculate MetadataLink','action':'recalculateMetaLink'},          {'label':'Recalculate MetadataLink','action':'recalculateMetaLink'},
         {'label':'Import Metadata File','action':'importMetaFileForm'},          {'label':'Import Metadata File','action':'importMetaFileForm'},
Line 1054  class ImageCollection(OrderedFolder, Per Line 1190  class ImageCollection(OrderedFolder, Per
   
     def ImportFiles2(self,RESPONSE=None):      def ImportFiles2(self,RESPONSE=None):
         """Import the existing files of a folder"""          """Import the existing files of a folder"""
         files=os.listdir(self.ImageStoragePath)          files=os.listdir(self.getImageStoragePath())
         ret=""          ret=""
         #print self.__dict__          #print self.__dict__
         for file in files:          for file in files:
             if not file[0]==".":              fn=os.path.splitext(file)[0]
                 if self.__dict__.has_key(file):              if not (file[0]=="."):
                   if self.__dict__.has_key(file) or self.__dict__.has_key(fn+'.tif') or self.__dict__.has_key(fn+'.tiff') :
   
                     ret=ret+"<br>"+file+" already exists!"                      ret=ret+"<br>"+file+" already exists!"
                 else:                  else:
Line 1071  class ImageCollection(OrderedFolder, Per Line 1208  class ImageCollection(OrderedFolder, Per
                     self._setObject(file,newObj)                      self._setObject(file,newObj)
         #print ret          #print ret
         #pt=PageTemplateFile('Products/ImageArchive/out.zpt')).__of__(self)          #pt=PageTemplateFile('Products/ImageArchive/out.zpt')).__of__(self)
         #print self.ImageStoragePath          #print self.getImageStoragePath()
   
         #scale thumb          #scale thumb
                   
         #self.scaleThumbs()          self.scaleThumbs()
   
         #scale standard          #scale standard
   
         #self.scaleWorkingVersions()          self.scaleWorkingVersions()
                   
   
         RESPONSE.redirect('manage_main')          RESPONSE.redirect('manage_main')
Line 1095  class ImageCollection(OrderedFolder, Per Line 1232  class ImageCollection(OrderedFolder, Per
   
     def ImportStructure(self,RESPONSE=None):      def ImportStructure(self,RESPONSE=None):
         """Import the existing files of a folder"""          """Import the existing files of a folder"""
         files=os.listdir(self.ImageStoragePath)          files=os.listdir(self.getImageStoragePath())
         ret=""          ret=""
         #print self.__dict__          #print self.__dict__
   
   
         for file in files:          for file in files:
                           
             if os.path.isdir(os.path.join(self.ImageStoragePath,file)):              if os.path.isdir(os.path.join(self.getImageStoragePath(),file)):
                 imageStoragePath=os.path.join(self.ImageStoragePath,file)                  ImageStoragePath=os.path.join(self.getImageStoragePath(),file)
                 imageViewerPath=os.path.join(self.ImageViewerPath,file)                  imageViewerPath=os.path.join(self.ImageViewerPath,file)
                 manage_AddImageCollection(self,file,file,imageStoragePath,imageViewerPath,self.defaultMetaString)                  manage_AddImageCollection(self,file,file,self.getImageStoragePath(),imageViewerPath,self.defaultMetaString)
                           
                 obj=getattr(self,file)                  obj=getattr(self,file)
                 obj.ImportStructure()                  obj.ImportStructure()
Line 1125  class ImageCollection(OrderedFolder, Per Line 1262  class ImageCollection(OrderedFolder, Per
                             """nothing yet"""                              """nothing yet"""
         #print ret          #print ret
         #pt=PageTemplateFile('Products/ImageArchive/out.zpt')).__of__(self)          #pt=PageTemplateFile('Products/ImageArchive/out.zpt')).__of__(self)
         #print self.ImageStoragePath          #print self.getImageStoragePath()
   
                 #scale thumb                  #scale thumb
                   
         #self.scaleThumbs()          self.scaleThumbs()
   
         #scale standard          #scale standard
   
         #self.scaleWorkingVersions()          self.scaleWorkingVersions()
                   
         if RESPONSE:          if RESPONSE:
                 RESPONSE.redirect('manage_main')                  RESPONSE.redirect('manage_main')
           
     def ImportFiles(self,RESPONSE=None):      def ImportFiles(self,RESPONSE=None):
         """Import the existing files of a folder"""          """Import the existing files of a folder"""
         files=os.listdir(self.ImageStoragePath)          files=os.listdir(self.getImageStoragePath())
         ret=""          ret=""
         #print self.__dict__          #print self.__dict__
         for file in files:          for file in files:
             if not file[0]==".":              fn=os.path.splitext(file)[0]
                 if self.__dict__.has_key(file):              if not (file[0]=="."):
                   if self.__dict__.has_key(file) or self.__dict__.has_key(fn+'.tif') or self.__dict__.has_key(fn+'.tiff') :
   
                     ret=ret+"<br>"+file+" already exists!"                      ret=ret+"<br>"+file+" already exists!"
   
                 else:                  else:
                     ret=ret+"<br>"+file+" created!"                      ret=ret+"<br>"+file+" created!"
                     newObj=ImageDigilib(file,file)                      newObj=ImageDigilib(file,file)
Line 1159  class ImageCollection(OrderedFolder, Per Line 1298  class ImageCollection(OrderedFolder, Per
                         """nothing yet"""                          """nothing yet"""
         #print ret          #print ret
         #pt=PageTemplateFile('Products/ImageArchive/out.zpt')).__of__(self)          #pt=PageTemplateFile('Products/ImageArchive/out.zpt')).__of__(self)
         #print self.ImageStoragePath          #print self.getImageStoragePath()
   
                 #scale thumb                  #scale thumb
                   
         #self.scaleThumbs()          self.scaleThumbs()
   
         #scale standard          #scale standard
   
Line 1180  class ImageCollection(OrderedFolder, Per Line 1319  class ImageCollection(OrderedFolder, Per
         pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','ChangeImageCollectionForm.zpt')).__of__(self)          pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','ChangeImageCollectionForm.zpt')).__of__(self)
         return pt()          return pt()
   
     def ChangeImageCollection(self,title,ImageStoragePath,ImageViewerPath,defaultMetaString,serverPath,RESPONSE=None):      def ChangeImageCollection(self,title,ImageViewerPath,defaultMetaString,serverPath,destBasis,srcBasis,RESPONSE=None):
         """Change"""          """Change"""
         self.title=title          self.title=title
         self.ImageStoragePath=ImageStoragePath  
         self.ImageViewerPath=ImageViewerPath          self.ImageViewerPath=ImageViewerPath
         self.defaultMetaString=defaultMetaString          self.defaultMetaString=defaultMetaString
         self.serverPath=serverPath          self.serverPath=serverPath
           self.destBasis=destBasis
           self.srcBasis=srcBasis
                   
         if RESPONSE is not None:          if RESPONSE is not None:
             RESPONSE.redirect('manage_main')              RESPONSE.redirect('manage_main')
Line 1726  def manage_AddImageCollectionForm(self): Line 1866  def manage_AddImageCollectionForm(self):
     pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','AddImageCollectionForm.zpt')).__of__(self)      pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','AddImageCollectionForm.zpt')).__of__(self)
     return pt()      return pt()
           
 def manage_AddImageCollection(self,id,title,ImageStoragePath,ImageViewerPath,defaultMetaString,RESPONSE=None):  def manage_AddImageCollection(self,id,title,ImageViewerPath,defaultMetaString,destBasis,srcBasis,serverPath,RESPONSE=None):
   
     """Add ImageCollection"""      """Add ImageCollection"""
     newObj=ImageCollection(id,title,ImageStoragePath,ImageViewerPath,defaultMetaString)      newObj=ImageCollection(id,title,ImageViewerPath,defaultMetaString,destBasis,srcBasis,serverPath=genericServerPath)
     self._setObject(id,newObj)      self._setObject(id,newObj)
           
     if RESPONSE is not None:      if RESPONSE is not None:
Line 1757  class ImageCollectionMD(ImageCollection, Line 1898  class ImageCollectionMD(ImageCollection,
           
     def ImportFiles(self,RESPONSE=None):      def ImportFiles(self,RESPONSE=None):
         """Import the existing files of a folder"""          """Import the existing files of a folder"""
         files=os.listdir(self.ImageStoragePath)          files=os.listdir(self.getImageStoragePath())
         ret=""          ret=""
         #print self.__dict__          #print self.__dict__
         for file in files:          for file in files:
             if not file[0]==".":  
                 if self.__dict__.has_key(file):              if not (file[0]=="."):
                   fn=os.path.splitext(file)[0]
                   if self.__dict__.has_key(file) or self.__dict__.has_key(fn+'.tif') or self.__dict__.has_key(fn+'.tiff') :
   
                     ret=ret+"<br>"+file+" already exists!"                      ret=ret+"<br>"+file+" already exists!"
   
                 else:                  else:
                     ret=ret+"<br>"+file+" created!"                      ret=ret+"<br>"+file+" created!"
                     newObj=ImageDigilib(file,file)                      newObj=ImageDigilib(file,file)
Line 1789  class ImageCollectionMD(ImageCollection, Line 1933  class ImageCollectionMD(ImageCollection,
                 #scale thumb                  #scale thumb
                   
                   
         #self.scaleThumbs()          self.scaleThumbs()
   
         #scale standard          #scale standard
   
         #self.scaleWorkingVersions()          self.scaleWorkingVersions()
           
           self.scaleToJpgs()
                   
         if RESPONSE:          if RESPONSE:
                 RESPONSE.redirect('manage_main')                  RESPONSE.redirect('manage_main')
Line 1827  class ImageCollectionMD(ImageCollection, Line 1973  class ImageCollectionMD(ImageCollection,
                   
         self.ZSQLAdd(args=args)          self.ZSQLAdd(args=args)
                   
           self.scaleThumbs()
           self.scaleWorkingVersions()
           
           getattr(self,fn).scaleToJpg()
         if RESPONSE:          if RESPONSE:
             return RESPONSE.redirect(self.REQUEST['URL1']+'/'+fn)              return RESPONSE.redirect(self.REQUEST['URL1']+'/'+fn)
         #return  self.REQUEST['URL1']+'/'+fileupload.filename          #return  self.REQUEST['URL1']+'/'+fileupload.filename
Line 1870  class ImageCollectionMD(ImageCollection, Line 2020  class ImageCollectionMD(ImageCollection,
   
     def searchDB(self,REQUEST=None,RESPONSE=None,xml=None):      def searchDB(self,REQUEST=None,RESPONSE=None,xml=None):
         """search"""          """search"""
         #context.ZSQLFind(_table='vision_main')  
         urlTmp=REQUEST['URL1']  
                   
         url=urlTmp+'/searchResultXML?-table=%s&'%self.imageCollectionConfig.getTable()+REQUEST['QUERY_STRING']          rc=[]
           fnIds={}
           for found in self.ZSQLInlineSearch(args=self.REQUEST.form):
               key=getattr(found,self.imageCollectionConfig.getKey())
               key=self.getImageByName(key,onlyName="yes")        
               rc.append((key,'',0))
               fnIds[key]=('',0)
                   
         if xml is None:          rc.sort()
             RESPONSE.redirect('xmlinput?url='+urllib.quote(url))          self.REQUEST.SESSION['filenames']=rc
           self.REQUEST.SESSION['filenamesIds']=fnIds
           
           overview=self.ZopeFind(self,obj_ids=['overview_selectedMD.html'])
               
           if overview:
                   return overview[0][1]()
         else:          else:
             RESPONSE.redirect(url)                  pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','overview_selectedMD.zpt')).__of__(self)
                   return pt()        
           
           pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','overview_selectedMD.zpt')).__of__(self)
           return pt()        
           
           #urlTmp=REQUEST['URL1']
           
           #url=urlTmp+'/searchResultXML?-table=%s&'%self.imageCollectionConfig.getTable()+REQUEST['QUERY_STRING']
           
           #if xml is None:
           #    RESPONSE.redirect('xmlinput?url='+urllib.quote(url))
           #else:
           #    RESPONSE.redirect(url)
                           
     def index_html(self,fn=None,selection=None,generic='No',REQUEST=None,RESPONSE=None):      def index_html(self,fn=None,selection=None,generic='No',REQUEST=None,RESPONSE=None):
         """main template collection"""          """main template collection"""
Line 2061  class ImageCollectionMD(ImageCollection, Line 2234  class ImageCollectionMD(ImageCollection,
                 return "ERROR: (%s %s) %s"%(sys.exc_info()[0],sys.exc_info()[1],xmldoc)                  return "ERROR: (%s %s) %s"%(sys.exc_info()[0],sys.exc_info()[1],xmldoc)
   
   
         images=dom.xpath("//image")          imagenames=dom.xpath("//imagename")
         rc=[]          rc=[]
         fnIds={}          fnIds={}
         for image in images:          for imagename in imagenames:
   
                 imagename=image.xpath('./imagename')[0]  
                               
                   #imagename=image.xpath('./imagename')[0]
                   #print "im",imagename
                                   
                                   
                                   
                 idnr=image.xpath('./idnr')[0]                  idnr=imagename.xpath('../idnr')[0]
                 id=getText(idnr.childNodes)                  id=getText(idnr.childNodes)
                 try:                  try:
                     numberOfPages=image.xpath('./numberOfPages')[0]                      numberOfPages=imagename.xpath('../numberOfPages')[0]
                 except:                  except:
                     numberOfPages=None                      numberOfPages=None
                                           
Line 2090  class ImageCollectionMD(ImageCollection, Line 2263  class ImageCollectionMD(ImageCollection,
                 texts=getText(imagename.childNodes).split("\n") #mehrere bilder in return getrennter liste                  texts=getText(imagename.childNodes).split("\n") #mehrere bilder in return getrennter liste
                 for text in texts:                  for text in texts:
                     if not text=="":                      if not text=="":
                           #print "a"
                         text=self.getImageByName(text,onlyName="yes")                          text=self.getImageByName(text,onlyName="yes")
                           #print "b"
                         try:                          try:
                                 rc.append((str(text),id,nop))                                  rc.append((str(text),id,nop))
                                 fnIds[str(text)]=(id,nop)                                  fnIds[str(text)]=(id,nop)
Line 2098  class ImageCollectionMD(ImageCollection, Line 2273  class ImageCollectionMD(ImageCollection,
                                 rc.append((repr(text),id,nop))                                  rc.append((repr(text),id,nop))
                                 fnIds[repr(text)]=(id,nop)                                  fnIds[repr(text)]=(id,nop)
                                   
           #print "done"
         rc.sort()          rc.sort()
         self.REQUEST.SESSION['filenames']=rc          self.REQUEST.SESSION['filenames']=rc
         self.REQUEST.SESSION['filenamesIds']=fnIds          self.REQUEST.SESSION['filenamesIds']=fnIds
Line 2134  def manage_AddImageCollectionMDForm(self Line 2309  def manage_AddImageCollectionMDForm(self
     pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','AddImageCollectionFormMD.zpt')).__of__(self)      pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','AddImageCollectionFormMD.zpt')).__of__(self)
     return pt()      return pt()
           
 def manage_AddImageCollectionMD(self,id,title,ImageStoragePath,ImageViewerPath,defaultMetaString,RESPONSE=None):  def manage_AddImageCollectionMD(self,id,title,ImageViewerPath,defaultMetaString,destBasis,srcBasis,serverPath,RESPONSE=None):
     """Add ImageCollection"""      """Add ImageCollection"""
     newObj=ImageCollectionMD(id,title,ImageStoragePath,ImageViewerPath,defaultMetaString)      newObj=ImageCollectionMD(id,title,ImageViewerPath,defaultMetaString,destBasis,srcBasis,serverPath)
     self._setObject(id,newObj)      self._setObject(id,newObj)
           
     if RESPONSE is not None:      if RESPONSE is not None:
Line 2274  def manage_AddImageZogiLib(self,id=None, Line 2449  def manage_AddImageZogiLib(self,id=None,
     self._setObject(id,newObj)      self._setObject(id,newObj)
     getattr(self,id).caption=caption[0:]      getattr(self,id).caption=caption[0:]
     if fileUpload:      if fileUpload:
         getattr(self,id).uploadImage(fileupload,self.ImageStoragePath)          getattr(self,id).uploadImage(fileupload,self.getImageStoragePath())
           
     if RESPONSE is not None:      if RESPONSE is not None:
         RESPONSE.redirect('manage_main')          RESPONSE.redirect('manage_main')

Removed from v.1.87  
changed lines
  Added in v.1.93


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