Diff for /ImageArchive/ImageArchive.py between versions 1.104 and 1.109

version 1.104, 2008/08/15 14:10:23 version 1.109, 2012/08/28 09:46:32
Line 3 Line 3
 genericServerPath="http://www.mpiwg-berlin.mpg.de/zogilib_images" #can be changed with main config  genericServerPath="http://www.mpiwg-berlin.mpg.de/zogilib_images" #can be changed with main config
   
   
 from Ft.Xml.Domlette import NonvalidatingReader  #from Ft.Xml.Domlette import NonvalidatingReader
 from OFS.Folder import Folder  from OFS.Folder import Folder
 from OFS.OrderedFolder import OrderedFolder  from OFS.OrderedFolder import OrderedFolder
 from OFS.SimpleItem import SimpleItem  from OFS.SimpleItem import SimpleItem
Line 308  class ImageDigilib(Folder,Persistent,Imp Line 308  class ImageDigilib(Folder,Persistent,Imp
     manage_options = Folder.manage_options+(      manage_options = Folder.manage_options+(
                   
         {'label':'Add Metadata','action':'addMetaObjectForm'},          {'label':'Add Metadata','action':'addMetaObjectForm'},
                   {'label':'View Info','action':'editImageDigilib'},
         )          )
   
       def editImageDigilib(self):
           """edit image date"""
           pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','editImageDigilib.zpt')).__of__(self)
           return pt()        
   
   
                   
     def getAccessRight(self):      def getAccessRight(self):
Line 321  class ImageDigilib(Folder,Persistent,Imp Line 326  class ImageDigilib(Folder,Persistent,Imp
           
     def isAccessible(self):      def isAccessible(self):
         """gives true if obejct is accessible taking the rights of the user into account"""          """gives true if obejct is accessible taking the rights of the user into account"""
         logTemp("isaccessible")          logTime("isaccessible")
         #TODO: implement rights, currently  true if external and false if internal, and true if user has role authenticated          #TODO: implement rights, currently  true if external and false if internal, and true if user has role authenticated
           
         username=self.REQUEST['AUTHENTICATED_USER']          username=self.REQUEST['AUTHENTICATED_USER']
Line 405  class ImageDigilib(Folder,Persistent,Imp Line 410  class ImageDigilib(Folder,Persistent,Imp
         """upload an Image from an Requast"""          """upload an Image from an Requast"""
         #path_name=self.ImageStoragePath          #path_name=self.ImageStoragePath
         fn = self.filename or splitPath(fileupload.filename)          fn = self.filename or splitPath(fileupload.filename)
           fn = os.path.splitext(fn)[0]+os.path.splitext(fileupload.filename)[1] # Extensions des gespeicherten Files sollte gleich dem hochgeladenen File sein.
         filename=path_name+"/"+fn          filename=path_name+"/"+fn
         filedata=fileupload.read()          filedata=fileupload.read()
         f=open(filename,"w")          f=open(filename,"w")
         f.write(filedata)          f.write(filedata)
         f.close()          f.close()
         self.filename = fn          self.filename = fn
           
         try:          try:
             os.chmod(filename,0664)              os.chmod(filename,0664)
         except:          except:
Line 529  class ImageDigilib(Folder,Persistent,Imp Line 536  class ImageDigilib(Folder,Persistent,Imp
             os.mkdir(path,0775)              os.mkdir(path,0775)
             os.chmod(path,0775)              os.chmod(path,0775)
                           
         newName=os.path.join(path,self.getId())          newName=os.path.join(path,self.getId()+str(time.time()))
   
         if os.path.exists(newName):          if os.path.exists(newName):
             logger("ImageArchive:scaleToJpg", logging.INFO, "%s already exists"%newName)              logger("ImageArchive:scaleToJpg", logging.INFO, "%s already exists"%newName)
Line 558  class ImageDigilib(Folder,Persistent,Imp Line 565  class ImageDigilib(Folder,Persistent,Imp
         #teste ob Dokumenten ordner schon vorhanden          #teste ob Dokumenten ordner schon vorhanden
         #imagePath=os.path.join(self.getImageStoragePath(),self.getId())          #imagePath=os.path.join(self.getImageStoragePath(),self.getId())
                   
           logging.error("updateImage:"+self.filename)
         identifyField="filename"          identifyField="filename"
                   
         if _fileupload and _fileupload.filename!="":          if _fileupload and _fileupload.filename!="":
             imagePath=os.path.join(self.getImageStoragePath(),self.filename)              imagePath=os.path.join(self.getImageStoragePath(),self.filename)
               idWithoutSuffix= os.path.splitext(self.getId())[0]
             path=os.path.join(self.getImageStoragePath(),"."+self.getId()+".dir")              path=os.path.join(self.getImageStoragePath(),"."+self.getId()+".dir")
                                   
             if not os.path.exists(path):              if not os.path.exists(path):
Line 585  class ImageDigilib(Folder,Persistent,Imp Line 594  class ImageDigilib(Folder,Persistent,Imp
           
             #lesen des upload files und schreiben              #lesen des upload files und schreiben
             filedata=_fileupload.read()              filedata=_fileupload.read()
             f=open(imagePath,"w") # if we wanted to have filename=id we should do it here!              
               #passe suffix an
               oldNameBase=os.path.splitext(imagePath)[0]
               uploadFileExt=os.path.splitext(_fileupload.filename)[1]
               
               newImagePath=oldNameBase+uploadFileExt
               
               f=open(newImagePath,"w") # if we wanted to have filename=id we should do it here!
               logging.error("saving:"+newImagePath)
             f.write(filedata)              f.write(filedata)
             f.close()              f.close()
             try:              try:
                 os.chmod(imagePath,0664)                  os.chmod(newImagePath,0664)
             except:              except:
                 pass                  pass
             #scale thumb              #scale thumb
Line 599  class ImageDigilib(Folder,Persistent,Imp Line 616  class ImageDigilib(Folder,Persistent,Imp
             #scale standard              #scale standard
           
             self.scaleWorkingVersions()              self.scaleWorkingVersions()
             self.scaleToJpg()              #self.scaleToJpg()
             if _rename:              if _rename:
                 self.renameImage(_fileupload.filename)                  self.renameImage(_fileupload.filename)
                   
               else: 
                   self.filename=os.path.splitext(self.filename)[0]+uploadFileExt # Aendere zumindest die Extensiion
             
           try: #todo: sollte nur aufgerufen werden, wenn eine Datenbank dahinter liegt.
         args=self.REQUEST.form          args=self.REQUEST.form
                 
         args['-identify']=identifyField+"="+args['_identifyField']          args['-identify']=identifyField+"="+args['_identifyField']
                     
         self.ZSQLChange(args=args)          self.ZSQLChange(args=args)
                     
           except:
               pass
           
         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 794  class ImageCollection(OrderedFolder, Per Line 817  class ImageCollection(OrderedFolder, Per
             
                 
         #ret=scaleStr          #ret=scaleStr
     #logger("ImageCollection:scale",logging.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 1269  class ImageCollection(OrderedFolder, Per Line 1292  class ImageCollection(OrderedFolder, Per
             if os.path.isdir(os.path.join(self.getImageStoragePath(),file)):              if os.path.isdir(os.path.join(self.getImageStoragePath(),file)):
                 ImageStoragePath=os.path.join(self.getImageStoragePath(),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,self.getImageStoragePath(),imageViewerPath,self.defaultMetaString)                  #manage_AddImageCollection(self,file,file,self.getImageStoragePath(),imageViewerPath,self.defaultMetaString)
                               manage_AddImageCollection(self,file,file,imageViewerPath,self.defaultMetaString,self.destBasis,self.srcBasis,self.serverPath)
                 obj=getattr(self,file)                  obj=getattr(self,file)
                 obj.ImportStructure()                  obj.ImportStructure()
             else:              else:
Line 2273  class ImageCollectionMD(ImageCollection, Line 2296  class ImageCollectionMD(ImageCollection,
         xmldoc=urllib.urlopen(url).read()          xmldoc=urllib.urlopen(url).read()
         #return xmldoc          #return xmldoc
         try:          try:
                 dom=NonvalidatingReader.parseUri(url)                  #dom=NonvalidatingReader.parseUri(url)
                   pass
   
         except:          except:
                 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)

Removed from v.1.104  
changed lines
  Added in v.1.109


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