Diff for /ImageArchive/ImageArchive.py between versions 1.98 and 1.103

version 1.98, 2006/07/24 17:31:06 version 1.103, 2007/01/31 14:24:17
Line 24  from threading import Thread Line 24  from threading import Thread
 import Queue  import Queue
 import cgi  import cgi
 import sys  import sys
 import zLOG  
 import shutil  import shutil
   
   import logging
   
   #ersetzt logging
   def logger(txt,method,txt2):
       """logging"""
       logging.info(txt+ txt2)
   
   
   
 from AccessControl import ClassSecurityInfo, getSecurityManager  from AccessControl import ClassSecurityInfo, getSecurityManager
   
 try:  try:
Line 499  class ImageDigilib(Folder,Persistent,Imp Line 508  class ImageDigilib(Folder,Persistent,Imp
   
             self.scaleWorkingVersions()              self.scaleWorkingVersions()
   
             self.scaleToJpg()              #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)
                   
Line 518  class ImageDigilib(Folder,Persistent,Imp Line 527  class ImageDigilib(Folder,Persistent,Imp
         newName=os.path.join(path,self.getId())          newName=os.path.join(path,self.getId())
   
         if os.path.exists(newName):          if os.path.exists(newName):
             zLOG.LOG("ImageArchive:scaleToJpg", zLOG.INFO, "%s already exists"%newName)              logger("ImageArchive:scaleToJpg", logging.INFO, "%s already exists"%newName)
         else:          else:
             try:              try:
                 os.rename(imagePath,newName)                  os.rename(imagePath,newName)
             except:              except:
                 zLOG.LOG("ImageArchive:scaleToJpg", zLOG.ERROR, "%s "%newName)                  logger("ImageArchive:scaleToJpg", logging.ERROR, "%s "%newName)
                 return False                  return False
                           
         ext= os.path.splitext(imagePath)[1].lower()          ext= os.path.splitext(imagePath)[1].lower()
Line 564  class ImageDigilib(Folder,Persistent,Imp Line 573  class ImageDigilib(Folder,Persistent,Imp
             #kopieren der bestehenden Version in den Versions ordner.              #kopieren der bestehenden Version in den Versions ordner.
             imageNewPath=os.path.join(path,"V%i_%s"%(versionNumber,self.filename))              imageNewPath=os.path.join(path,"V%i_%s"%(versionNumber,self.filename))
             try:                  try:    
                     #zLOG.LOG("ImageArchive:updateImage", zLOG.INFO, "rename: %s -> %s"%(imagePath,imageNewPath))                      #logger("ImageArchive:updateImage", logging.INFO, "rename: %s -> %s"%(imagePath,imageNewPath))
                     os.rename(imagePath,imageNewPath)                      os.rename(imagePath,imageNewPath)
             except:              except:
                 zLOG.LOG("ImageArchive:updateImage", zLOG.ERROR, "rename: %s -> %s didn't work!"%(imagePath,imageNewPath))                        logger("ImageArchive:updateImage", logging.ERROR, "rename: %s -> %s didn't work!"%(imagePath,imageNewPath))      
           
             #lesen des upload files und schreiben              #lesen des upload files und schreiben
             filedata=_fileupload.read()              filedata=_fileupload.read()
Line 757  class ImageCollection(OrderedFolder, Per Line 766  class ImageCollection(OrderedFolder, Per
             fileStr=" -dir=%s"%fileTmp              fileStr=" -dir=%s"%fileTmp
             scaleStr=scaleStr+fileStr              scaleStr=scaleStr+fileStr
         else:          else:
             zLOG.LOG("ImageCollection:scale",zLOG.ERROR,"no directory or filename given")              logger("ImageCollection:scale",logging.ERROR,"no directory or filename given")
             return False              return False
                   
         if dest is not None:          if dest is not None:
             destStr=" -dest=%s"%os.path.join(destBasis,dest)              destStr=" -dest=%s"%os.path.join(destBasis,dest)
             scaleStr=scaleStr+destStr              scaleStr=scaleStr+destStr
         else:          else:
             zLOG.LOG("ImageCollection:scale",zLOG.ERROR,"no destionation given")              logger("ImageCollection:scale",logging.ERROR,"no destionation given")
             return False              return False
                   
         if scaleTo:          if scaleTo:
Line 774  class ImageCollection(OrderedFolder, Per Line 783  class ImageCollection(OrderedFolder, Per
             scaleByStr=" -scaleby=%s"%scaleBy              scaleByStr=" -scaleby=%s"%scaleBy
             scaleStr=scaleStr+scaleByStr              scaleStr=scaleStr+scaleByStr
         else:          else:
             zLOG.LOG("ImageCollection:scale",zLOG.ERROR,"no destionation given")              logger("ImageCollection:scale",logging.ERROR,"no destionation given")
             return False              return False
             
                 
         #ret=scaleStr          #ret=scaleStr
     #zLOG.LOG("ImageCollection:scale",zLOG.INFO,scaleStr)      #logger("ImageCollection:scale",logging.INFO,scaleStr)
         ret=os.popen2(scaleStr,1)[1].read()          ret=os.popen2(scaleStr,1)[1].read()
     
         if RESPONSE:          if RESPONSE:
Line 1731  class ImageCollection(OrderedFolder, Per Line 1740  class ImageCollection(OrderedFolder, Per
         else:          else:
             return ids[(row-1)*numberOfColumns:]              return ids[(row-1)*numberOfColumns:]
                   
     def thumblistSelected_old(self):  
         """main template collection"""  
         pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','thumbselected.zpt')).__of__(self)  
         return pt()  
   
     def thumblistSelected(self):      def thumblistSelected(self):
         """main template collection"""          """main template collection"""
         pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','thumbselected2.zpt')).__of__(self)          pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','thumbselected2.zpt')).__of__(self)
         return pt()          return pt()
           
     def thumblist_old(self):  
         """main template collection"""  
         pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','thumbs.zpt')).__of__(self)  
         return pt()  
   
     def thumblist(self):      def thumblist(self):
         """main template collection"""          """main template collection"""
Line 1932  class ImageCollectionMD(ImageCollection, Line 1933  class ImageCollectionMD(ImageCollection,
                     ret=ret+"<br>"+file+" already exists!"                      ret=ret+"<br>"+file+" already exists!"
   
                 else:                  else:
                       logger("ImageArchiveMD:import", logging.INFO, "adding ZOPE: %s"%file)
                     ret=ret+"<br>"+file+" created!"                      ret=ret+"<br>"+file+" created!"
                     newObj=ImageDigilib(file,file)                      newObj=ImageDigilib(file,file)
                     #print newObj,file                      #print newObj,file
Line 1941  class ImageCollectionMD(ImageCollection, Line 1943  class ImageCollectionMD(ImageCollection,
                     except:                      except:
                         """nothing yet"""                          """nothing yet"""
                                                   
                                       # check entry in database
                     args={}                      args={}
                     args['_table']=self.imageCollectionConfig.getTable()                      args['_table']=self.imageCollectionConfig.getTable()
                     args[self.imageCollectionConfig.getKey()]=file                      args[self.imageCollectionConfig.getKey()]=file
                                           
                     if not self.ZSQLInlineSearch(args=args):                  if not self.ZSQLInline(args=args):
                       logger("ImageArchiveMD:import", logging.INFO, "adding DB: %s"%file)
                         self.ZSQLAdd(args=args)                              self.ZSQLAdd(args=args)    
    
         #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.ImageStoragePath
Line 1961  class ImageCollectionMD(ImageCollection, Line 1965  class ImageCollectionMD(ImageCollection,
   
         self.scaleWorkingVersions()          self.scaleWorkingVersions()
                   
         self.scaleToJpgs()          #self.scaleToJpgs()
                   
         if RESPONSE:          if RESPONSE:
                 RESPONSE.redirect('manage_main')                  RESPONSE.redirect('manage_main')
Line 2045  class ImageCollectionMD(ImageCollection, Line 2049  class ImageCollectionMD(ImageCollection,
                   
         rc=[]          rc=[]
         fnIds={}          fnIds={}
   
         for found in self.ZSQLInlineSearch(args=self.REQUEST.form):          for found in self.ZSQLInlineSearch(args=self.REQUEST.form):
             key=getattr(found,self.imageCollectionConfig.getKey())              key=getattr(found,self.imageCollectionConfig.getKey())
             key=self.getImageByName(key,onlyName="yes")                      key=self.getImageByName(key,onlyName="yes")        
Line 2247  class ImageCollectionMD(ImageCollection, Line 2252  class ImageCollectionMD(ImageCollection,
         #return url          #return url
                   
         url=urllib.unquote(url)          url=urllib.unquote(url)
        
           url=url.replace(" ","+") # ersetze Leerzeichen in der URL durch "+"
           print url
         xmldoc=urllib.urlopen(url).read()          xmldoc=urllib.urlopen(url).read()
         #return xmldoc          #return xmldoc
         try:          try:
Line 2308  class ImageCollectionMD(ImageCollection, Line 2316  class ImageCollectionMD(ImageCollection,
                 pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','overview_selectedMD.zpt')).__of__(self)                  pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','overview_selectedMD.zpt')).__of__(self)
                 return pt()                          return pt()        
                   
         pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','overview_selectedMD.zpt')).__of__(self)  
         return pt()          
   
     def selection(self):      def selection(self):
         """show only selected"""          """show only selected"""

Removed from v.1.98  
changed lines
  Added in v.1.103


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