Skip to content. | Skip to navigation

Why doesn't my Python code work from a Python Script?

http://plone.org/documentation/faq/restricted-python-scripts

 

Why doesn't my Python code work from a Python Script?

I have added a Python Script with classes or imports, why won't they work?

« Back to Table of Contents

Python Scripts product provides support for restricted execution of Python scripts, exposing them as callable objects within the Zope environment.

These scripts are restricted for security reasons, and to stop you from invoking code that could make your server consume an infinite amount of CPU and/or memory (this is possible with the re module, for example).

If you want unrestricted Python code, it should live on the file system as a Zope Product or as a Zope external method, not in Python scripts that are added through the web or in skins.

For extensive information about this, and for how to make additional modules available, please consult the following file in your Zope instance:

/lib/python/Products/PythonScripts/README.txt

Keep in mind that using allow_module() is not a solution for every use-case.  allow_module() is supposed to work with Python modules implemented in Python itself but no necessarily with Python module (extensions) implemented in C.

For PythonScript functionality without restrictions you might check out TrustedExecutables by Dieter Maurer (be careful since TrustedExecutables might introduce security problems since none of the Zope security checks apply).

When you are working with Zope 3 technology then you should implement your functionalities using Zope 3 browser views
Document Actions