[Zope] Re: Generating and Downloading PDF

Dennis Allison allison at sumeru.stanford.EDU
Wed Mar 2 03:08:28 EST 2005


Python Scripts are protected and cannot access the file system.  Put your 
code in an External Method which is not restricted.

On Wed, 2 Mar 2005, Wolfram Kraus wrote:

> 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
> 
> _______________________________________________
> Zope maillist  -  Zope at 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 )
> 



More information about the Zope mailing list