[Zope] importing an existing python module into Zope python script?

Rachel Willmer rachel_lists at willmer.org
Fri Jan 30 10:54:35 EST 2004


OK, so I'm now convinced that the way forward is to use a Product 
wrapper around the python module. (Thanks to Dieter, Sean, Andrew and 
Paul for responding...)

But, I'm still struggling with getting it to work :-(

Using the lib/python/PythonScripts/README as a reference:

a) I create a directory lib/python/GlobalModules

b) I create __init__.py which looks like this...

from Products.PythonScripts.Utility import allow_module
allow_module('base64')

c) I restart the Zope server in development mode, and configure the 
GlobalModules product to auto-refresh.

d) I then create a Python Script file which looks like this:

from Products.GlobalModules import base64
def testing() :
	print base64.encodestring("hello")
	return printed

e) I call the script and get

Error Type: NameError
Error Value: global name 'base64' is not defined

What else do I need to do to get this to work? or, what am I doing wrong?

(Note, I'm using a simple example here with a builtin function, because 
I thought that would make it clearer, but what I really want to do is 
use a module of my own)

Thanks for any more pointers.

Rachel



More information about the Zope mailing list