2 Mar
2005
2 Mar
'05
7:35 a.m.
Fernando Lujan wrote:
I'm using the following code inside a python script, and I receive the message:
Error Type: Unauthorized Error Value: You are not allowed to access open in this context
Code:
import os file = "/usr/local/dc/zope-2.6.0/test.pdf" f = os.open(file) data = f.read() f.close() R = self.REQUEST.RESPONSE R.setHeader('content-type', 'application/pdf') R.write(data)
You have to put this in an external Method, e.g getPDF(self), because you don't have access to os from Python scripts inside Zope. BTW: No need to import os here, just use the builtin open function, albeit you still have to use an external method. HTH, Wolfram