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)
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
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@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 )
Wolfram Kraus wrote:
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.
Either that or provide appropriate security declarations in a python product. See Products/PythonScripts/standard.py for examples. cheers, Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
This will not answer your question Fernando but did you had a look at RMLPageTemplate? http://www.contentmanagementsoftware.info/zope/RMLPageTemplate http://openapp.biz/devel/RMLPageTemplate-0.3.tgz/file_view On Wed, 02 Mar 2005 09:29:25 +0000, Chris Withers <chris@simplistix.co.uk> wrote:
Wolfram Kraus wrote:
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.
Either that or provide appropriate security declarations in a python product. See Products/PythonScripts/standard.py for examples.
cheers,
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 )
participants (5)
-
Chris Withers -
Dennis Allison -
Fernando Lujan -
Remy Pinsonnault -
Wolfram Kraus