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

Dieter Maurer dieter at handshake.de
Fri Jan 30 14:30:52 EST 2004


Rachel Willmer wrote at 2004-1-30 15:54 +0000:
>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.

What is the "GlobalModules" product?

Products usually do not live in "lib/python" but in a "Products"
folder.

Only products can be refreshed.


>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

Your code above cannot produce this error...

  Whenever you see such an error, you must look at the
  traceback (via the "error_log" object in your Zope "Root Folder").
  It tells you precisely where the error was raised.

  In your case, it will show you that this is not in the code
  you have shown above (or you did not show us all the relevant
  code -- e.g. a call for "testing").

-- 
Dieter



More information about the Zope mailing list