[Zope-dev] Importing Custom Python Classes (fwd)

D. Bickle dbickle at uvic.ca
Thu Feb 19 14:53:22 EST 2004



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.





More information about the Zope-Dev mailing list