Jonathan wrote:
 > Try something like:


fileObj = context.restrictedTraverse('/folderA/folderB/printsbestand.pdf')
fileData = context.printsbestand()
fileObj.update_data(fileData, content_type='application/pdf', size=len(fileData) )

Warning: untested!
Look in the ZopeBook for more info.

hth

Jonathan


Yes! After getting an Unauthorized exception in Zope because I used a Python script and the method updata_data has permission Python only, I switched to an External Method. The new file is beeing uploaded, or updated if it already exists, and the assigned security roles are kept intact. This is how the external method turned out:

def uploadPdf(self):
   fileDir = '/bla/bla/'
   fileName = 'file.pdf'
   path_list = self.getPhysicalPath()
   path = "/".join(path_list) + "/" + fileName
   f = open(fileDir + fileName)
   fileBody = f.read()
   f.close

   try:
self.manage_addFile(fileName, fileBody, content_type='application/pdf')
   except:
      fileObj = self.restrictedTraverse(path)
fileObj.update_data(fileBody, content_type='application/pdf', size=len(fileBody))


Greetings,

Leandros


_______________________________________________
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 )

Reply via email to