How do you import your own python class modules into Zope? Here is what I've done: In lib/python/Products I created a directory called MyScriptModules which contains the following: First I import the required Modules: from Product.PythonScripts.Utility import allow_module, allow_class from AccessControl import ModuleSecurityInfo, ClassSecurityInfo from Globals import InitializeClass Then I add the security declarations: from ClassModule.ClassModule import Class1 allow_module('ClassModule.ClassModule') allow_class(Class1) I created a ClassModule directory in the Products directory and placed ClassModule.py class module in it. I then rebooted the Zope server. Now everytime I try this: from ClassModule.ClassModule import Class1 I get this error: import of ClassModule.ClassModule is unauthorized. I have read somewhere that in order to create new Products in Zope you have to meet some Zope API requirements like assigning certain class attributes. Is this true? If so where can I find some documentation? Is there a better way to import custom Python class modules than the way described above? Thanks in advance.
On Wednesday 18 February 2004 06:01 pm, D. Bickle wrote:
I have read somewhere that in order to create new Products in Zope you have to meet some Zope API requirements like assigning certain class attributes. Is this true? If so where can I find some documentation?
I find this http://www.zope.org/Documentation/Books/ZDG/ extremely helpful, even though it is officially a bit out of date (2.4). It's still pretty accurate. Cheers, Terry -- Terry Hancock ( hancock at anansispaceworks.com ) Anansi Spaceworks http://www.anansispaceworks.com
D. Bickle wrote at 2004-2-18 16:01 -0800:
How do you import your own python class modules into Zope? ... Then I add the security declarations:
from ClassModule.ClassModule import Class1 allow_module('ClassModule.ClassModule') allow_class(Class1)
I created a ClassModule directory in the Products directory and placed ClassModule.py class module in it.
I then rebooted the Zope server.
Now everytime I try this: from ClassModule.ClassModule import Class1 I get this error: import of ClassModule.ClassModule is unauthorized.
Are you sure that your module is imported? If not, your security declaration are never executed (and therefore ineffective). -- Dieter
Hmm...The module seems to be importing fine at the python command line. Zope complains that it is unauthorized so I am assuming it is being imported. On Thu, 19 Feb 2004, Dieter Maurer wrote:
D. Bickle wrote at 2004-2-18 16:01 -0800:
How do you import your own python class modules into Zope? ... Then I add the security declarations:
from ClassModule.ClassModule import Class1 allow_module('ClassModule.ClassModule') allow_class(Class1)
I created a ClassModule directory in the Products directory and placed ClassModule.py class module in it.
I then rebooted the Zope server.
Now everytime I try this: from ClassModule.ClassModule import Class1 I get this error: import of ClassModule.ClassModule is unauthorized.
Are you sure that your module is imported? If not, your security declaration are never executed (and therefore ineffective).
-- Dieter
D. Bickle wrote at 2004-2-19 12:17 -0800:
Hmm...The module seems to be importing fine at the python command line. Zope complains that it is unauthorized so I am assuming it is being imported.
Security declarations to allow module import must be in a module that is imported from trusted code (usually a product's "__init__.py" but that is not necessary). To put the declarations in the module itself will not help (unless this module is imported from trusted code before you try to import it from TTW code).
On Thu, 19 Feb 2004, Dieter Maurer wrote:
D. Bickle wrote at 2004-2-18 16:01 -0800:
How do you import your own python class modules into Zope? ... Then I add the security declarations:
from ClassModule.ClassModule import Class1 allow_module('ClassModule.ClassModule') allow_class(Class1)
I created a ClassModule directory in the Products directory and placed ClassModule.py class module in it.
I then rebooted the Zope server.
Now everytime I try this: from ClassModule.ClassModule import Class1 I get this error: import of ClassModule.ClassModule is unauthorized.
Are you sure that your module is imported? If not, your security declaration are never executed (and therefore ineffective).
-- Dieter
participants (3)
-
D. Bickle -
Dieter Maurer -
Terry Hancock