Re: [Zope] How to Update files that are already uploaded
Jonathan wrote: File objects have a method called 'update_data' which may be of use. I'd suggest manage_upload instead... Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] How to Update files that are already uploaded
File objects have a method called 'update_data' which may be of use. Look in the ZopeBook for details. Jonathan - Original Message - From: Mike Jakowlew To: zope@zope.org Sent: Thursday, December 01, 2005 12:12 PM Subject: [Zope] How to Update files that are already uploaded Hi all,I'm trying to update a file thats already been uploaded. I can't figure out what command to use, "update_data"/"manage_upload"/"manage_edit". I've settled (so far) on manage_upload but it doesn't work. I get the error: Error Type: AttributeError Error Value:manage_uploadmy code:_# Takes the filename from a form searches my ZSQL method for the existence of the file, and then should update the file. REQUEST=context.REQUESTfilename = REQUEST.form.get('file')filename=filename.split('\\')[-1]result=container.Show_filename_selected(filename=filename)if result: fname= container.Show_filename_selected (filename=filename).tuples()[0][3] context.manage_upload([filename,REQUEST]) return "File Exists... UPDATE: " + filenameelse: return "File Does NOT Exist: " + filename_ What am I doing wrong? Am I using the wrong command?Thanks in advance,mjakowlew ___Zope maillist - Zope@zope.orghttp://mail.zope.org/mailman/listinfo/zope** No cross posts or HTML encoding! **(Related lists - http://mail.zope.org/mailman/listinfo/zope-announcehttp://mail.zope.org/mailman/listinfo/zope-dev ) ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] How to Update files that are already uploaded
Am Donnerstag, den 01.12.2005, 12:12 -0500 schrieb Mike Jakowlew: Hi all, I'm trying to update a file thats already been uploaded. I can't figure out what command to use, update_data/manage_upload/manage_edit. I've settled (so far) on manage_upload but it doesn't work. I get the error: Error Type: AttributeError Error Value: manage_upload my code: _ # Takes the filename from a form searches my ZSQL method for the existence of the file, and then should update the file. REQUEST=context.REQUEST filename = REQUEST.form.get('file') filename=filename.split('\\')[-1] result=container.Show_filename_selected(filename=filename) if result: fname= container.Show_filename_selected (filename=filename).tuples()[0][3] context.manage_upload([filename,REQUEST]) return File Exists... UPDATE: + filename else: return File Does NOT Exist: + filename _ What am I doing wrong? Am I using the wrong command? Well, first of all where comes the ZSQL Method into the game? ZODB is already a database and knows best which objects exist and which do not. Also you need to acquire the actual object if its there: if has_attr(container.Filerepository,fileid): fileobj=getattr(container.Filerepository,fileid) fileobj.manage_upload( ...) return File %s exists. Updated it. % fileid else: container.Filerepository.manage_addFile(...) sketchy but you should get the picture. ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )