--- ImageArchive/ImageArchive.py 2008/08/15 14:10:23 1.104 +++ ImageArchive/ImageArchive.py 2008/08/18 13:27:42 1.105 @@ -308,9 +308,14 @@ class ImageDigilib(Folder,Persistent,Imp manage_options = Folder.manage_options+( {'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): @@ -405,12 +410,14 @@ class ImageDigilib(Folder,Persistent,Imp """upload an Image from an Requast""" #path_name=self.ImageStoragePath 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 filedata=fileupload.read() f=open(filename,"w") f.write(filedata) f.close() self.filename = fn + try: os.chmod(filename,0664) except: @@ -529,7 +536,7 @@ class ImageDigilib(Folder,Persistent,Imp os.mkdir(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): logger("ImageArchive:scaleToJpg", logging.INFO, "%s already exists"%newName) @@ -558,10 +565,12 @@ class ImageDigilib(Folder,Persistent,Imp #teste ob Dokumenten ordner schon vorhanden #imagePath=os.path.join(self.getImageStoragePath(),self.getId()) + logging.error("updateImage:"+self.filename) identifyField="filename" if _fileupload and _fileupload.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") if not os.path.exists(path): @@ -581,15 +590,22 @@ class ImageDigilib(Folder,Persistent,Imp #logger("ImageArchive:updateImage", logging.INFO, "rename: %s -> %s"%(imagePath,imageNewPath)) os.rename(imagePath,imageNewPath) except: - logger("ImageArchive:updateImage", logging.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 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! f.write(filedata) f.close() try: - os.chmod(imagePath,0664) + os.chmod(newImagePath,0664) except: pass #scale thumb @@ -603,13 +619,19 @@ class ImageDigilib(Folder,Persistent,Imp if _rename: self.renameImage(_fileupload.filename) + else: + self.filename=os.path.splitext(self.filename)[0]+uploadFileExt # Aendere zumindest die Extensiion - args=self.REQUEST.form + try: #todo: sollte nur aufgerufen werden, wenn eine Datenbank dahinter liegt. + 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: RESPONSE.redirect(self.aq_parent.absolute_url()+"?filename="+self.filename) @@ -794,7 +816,7 @@ class ImageCollection(OrderedFolder, Per #ret=scaleStr - #logger("ImageCollection:scale",logging.INFO,scaleStr) + logger("ImageCollection:scale",logging.INFO,scaleStr) ret=os.popen2(scaleStr,1)[1].read() if RESPONSE: