[Zope] generating an acquisition wrapper from generated code

davelists2 at peoplemerge.com davelists2 at peoplemerge.com
Fri Jan 14 22:26:37 EST 2005


Hi all,

====Aclass.py====
class Aclass(ZSI.TCcompound.Struct):
   def __init__:
     self._attr = "Attribute"
   def getAttr():
     return self.attr

====myTool.py====
from Aclass import Aclass
from Globals import InitializeClass
from OFS.SimpleItem import SimpleItem
from AccessControl import ClassSecurityInfo
from Products.CMFCore.utils import getToolByName, UniqueObject
from Products.CMFCore import CMFCorePermissions

class myTool(SimpleTool,UniqueObject):
  meta_type="myTool"
  id="myTool"
  def getAclass(self):
    inter = [base.Aclass(),]
    return inter

Now I want to myTool.getAclass().getAttr()
What's by importing myTool from unrestricted python, there's no problem.

When I access the tool from a (restricted) script or ZPT, it gives me:
   Insufficient Privileges
   or
   AccessControl.unauthorized.Unauthorized: You are not allowed to access 'getAttr' in this context.

I gather (thanks kosh at freenode#zope) that I need to wrap the objects in inter in an acquisition wrapper. But I can't inherit from SimpleItem as well as ZSI.TCcompound.Struct:

File "/usr/lib/python2.3/site-packages/ZSI/TCcompound.py", line 65, in __init__
    raise TypeError('pyclass must be None or a class, not <extension class ExtensionClass at f6b..>

Any Suggestions?

Thanks... And sorry for my bad python.  This pseudocode should be an accurate representation of what I get from ZSI's wsdl2py from Amazon's Web Services 3.0 WSDL.  Complex stuff, so try to not suggest something that would require I change Aclass -- been down that road already.


More information about the Zope mailing list