[Zope] Allowing access to Zope Product in Control Panel
kapil thangavelu
kthangavelu@earthlink.net
Fri, 29 Mar 2002 14:18:59 -0800
On Thursday 28 March 2002 08:02 pm, Itai Tavor wrote:
> Hi,
>
> I have a python Product MyProduct, defining a class MyClass. I want
> to be able to do two things with this class from a Python Script:
>
> - Access a property defined in the class without creating an instance
> of the class
>
> class MyClass(SimpleItem):
> menu = ('a', 'b', 'c')
>
> In Python Script: menu =
> context.Control_Panel.MyProduct.MyClass.MyClass.menu
>
> - Create an instance of MyClass without doing registerClass on it.
>
> The question is, how do I create the right permissions so the above
> can be done? I tried playing with the various methods detailed in
> PythonScripts/module_access_examples.py but didn't get anywhere.
i would do the above with some accessor functions in a Utility module of the
product and then use PythonScripts Modules allow access utility for example.
#Utils.py
from Products.PythonScripts.Utility import allow_module
from MyModule import MyClass
allow_module('MyProduct.Utils')
def myclass_factory(*args):
return MyClass(*args)
def myclass_attr_access(name):
return getattr(MyClass, name, None)
in a python script
from MyProducts.Utils import myclass_attr_access
etc...
-kapil