[Zope] Re: Generating and Downloading PDF
Wolfram Kraus
kraus at hagen-partner.de
Wed Mar 2 02:35:11 EST 2005
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
More information about the Zope
mailing list