[Zope] Interfaces to imported python modules

Matt matt@inuan.com
Thu, 24 Jul 2003 17:04:28 +1200


So after some experimentation I found I need to create access controlled 
proxy objects to all object definitions in a module I want to use which 
is in site-packages of the python distribution.  It was lucky that I 
used a factory in that external module.  But perhaps there is a simpler 
way.  In the example below I had Class Data creating an ObjectA() and 
assigning it to self.data.  This object actually references many other 
objects of different classes which in turn reference many other types of 
objects.  If I had an instance of Data available to a python script, say 
called data, and I wanted to go

data.objectRefB.objectRefC.someMethod() 

where objectRefC is an attribute of the object that is the value of 
objectRefB,

then I also need to proxy that second object class so that it is 
available to the python script in Zope.  Is there any way to proxy only 
ObjectA and tell it to make public all interfaces of any object that can 
be referenced through it?  I can't seem to find information on the ZDG 
that suggests I can.

regards
Matt


Dieter Maurer wrote:

>Matt wrote at 2003-7-23 18:32 +1200:
> > ...
> > I seem to be having a problem accessing attributes and methods of 
> > objects created inside a custom Zope product from python scripts and 
> > ZPTs.
>
>Whenever you have authorization problems, Shane's "VerboseSecurity"
>may help you.
>
> > ...
> >     def createAndAddDataObject( self ):
> >         self.dataObjects.append( Data( ) )
> > 
> >     def getDataObjects( self ):
> >         """
> >         return the dara
> >         """
> >         return self.dataObjects
> > 
> > 
> > Class Data:
> > 
> >     def __init__( self ):
> >         self.data = ObjectA()
> > ...
> > The problem is that I can call a method such as getDataObjects from a 
> > python script and get back a list of objects of type Data.  However I 
> > cannot access the attributes or methods of the ".data" attributes of 
> > these Data objects.
>
>Your "ObjectA" instances must have security declarations.
>
>Unless they derive from "Acquisition.[Im|Ex]plicite",
>they must be public.
>
>The ZDG should provide the details.
>
>
>Dieter
>
>
>  
>