[Zope] Python Classes and Zope.
Martijn Pieters
mj at zopatista.com
Thu Dec 1 10:56:18 EST 2005
On 12/1/05, Fernando Lujan <fernando.lujan at terra.com.br> wrote:
> There's a way to use a Python class inside zope?
>
> For instance, if I create the class:
>
> class MyClass:
> "A simple example class"
> i = 12345
> def f(self):
> return 'hello world'
>
> Can I invoke the following code inside a Python Script?
>
> x = MyClass()
> x.f()
Any Python code can be used from a Python Script, as long as it has
been marked safe for importing into a restricted code. So, yes, you
can define your Python class in a Product, but you must mark it safe
for use in scripts. You can then import your code into the script and
use it there.
In lib/python/Products/PythonScripts/module_access_examples.py you'll
find a series of examples that explain how to mark code safe for use
in restricted code.
Martijn Pieters
More information about the Zope
mailing list