generating an acquisition wrapper from generated code
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@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.
davelists2@peoplemerge.com wrote:
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@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. _______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Aclass needs to be inherited from Acquisition.Explcitit or Implicit and and in myTool: def getAclass(self): inter = [base.Aclass().__of__(self),] return inter hope this helps maybe you need to add security declarations to your class
On Sat, Jan 15, 2005 at 10:40:30AM +0100, Bernd Dorn wrote:
Aclass needs to be inherited from Acquisition.Explcitit or Implicit and and in myTool: def getAclass(self): inter = [base.Aclass().__of__(self),] return inter
I can post more code if necessary, but: Somehow, having already inherited from ZSI.TCcompound.Struct, I cannot also inherit from Acquisition.Explicit: Traceback (most recent call last): File "<string>", line 1, in ? File "/usr/lib/zope/lib/python/Zope/__init__.py", line 51, in app startup() File "/usr/lib/zope/lib/python/Zope/__init__.py", line 47, in startup _startup() File "/usr/lib/zope/lib/python/Zope/App/startup.py", line 45, in startup OFS.Application.import_products() File "/usr/lib/zope/lib/python/OFS/Application.py", line 637, in import_products import_product(product_dir, product_name, raise_exc=debug_mode) File "/usr/lib/zope/lib/python/OFS/Application.py", line 660, in import_product product=__import__(pname, global_dict, global_dict, silly) File "/var/lib/zope/Products/ProductTool/__init__.py", line 2, in ? from Products.ProductTool import ProductGhost,AmazonProduct File "/var/lib/zope/Products/ProductTool/AmazonProduct.py", line 7, in ? from AmazonSearch_services import * File "AmazonSearch_services.py", line 3020, in ? class ActorSearchResponseWrapper(ActorSearchResponse): File "AmazonSearch_services.py", line 3023, in ActorSearchResponseWrapper typecode = ActorSearchResponse(name='ActorSearchRequestResponse', ns='http://soap.amazon.com') File "AmazonSearch_services.py", line 3011, in __init__ self._return = ProductInfo_Def() File "/var/lib/zope/Products/ProductTool/AmazonSearch_services_types.py", line 1857, in __init__ TClist = [ZSI.TC.String(pname="TotalResults",aname="_TotalResults", optional=1), ZSI.TC.String(pname="TotalPages",aname="_TotalPages", optional=1), ZSI.TC.String(pname="ListName",aname="_ListName", optional=1), DetailsArray_Def(name="Details", ns=ns, optional=1), ] File "/var/lib/zope/Products/ProductTool/AmazonSearch_services_types.py", line 1308, in __init__ ZSI.TCcompound.Array.__init__(self, 'arrayTypeNS:Details[]', Details_Def(name=None,typed=0), pname=name, aname='_%s' % name, oname='%s xmlns:arrayTypeNS="http://soap.amazon.com"' % name, **kw) File "/var/lib/zope/Products/ProductTool/AmazonSearch_services_types.py", line 1791, in __init__ aname=aname, oname=oname, File "/usr/lib/python2.3/site-packages/ZSI/TCcompound.py", line 65, in __init__ raise TypeError('pyclass must be None or a class, not ' + TypeError: pyclass must be None or a class, not <extension class ExtensionClass at f6be67c0>
davelists2@peoplemerge.com wrote:
On Sat, Jan 15, 2005 at 10:40:30AM +0100, Bernd Dorn wrote:
Aclass needs to be inherited from Acquisition.Explcitit or Implicit and and in myTool: def getAclass(self): inter = [base.Aclass().__of__(self),] return inter
I can post more code if necessary, but:
Somehow, having already inherited from ZSI.TCcompound.Struct, I cannot also inherit from Acquisition.Explicit:
Traceback (most recent call last): File "<string>", line 1, in ? File "/usr/lib/zope/lib/python/Zope/__init__.py", line 51, in app startup() File "/usr/lib/zope/lib/python/Zope/__init__.py", line 47, in startup _startup() File "/usr/lib/zope/lib/python/Zope/App/startup.py", line 45, in startup OFS.Application.import_products() File "/usr/lib/zope/lib/python/OFS/Application.py", line 637, in import_products import_product(product_dir, product_name, raise_exc=debug_mode) File "/usr/lib/zope/lib/python/OFS/Application.py", line 660, in import_product product=__import__(pname, global_dict, global_dict, silly) File "/var/lib/zope/Products/ProductTool/__init__.py", line 2, in ? from Products.ProductTool import ProductGhost,AmazonProduct File "/var/lib/zope/Products/ProductTool/AmazonProduct.py", line 7, in ? from AmazonSearch_services import * File "AmazonSearch_services.py", line 3020, in ? class ActorSearchResponseWrapper(ActorSearchResponse): File "AmazonSearch_services.py", line 3023, in ActorSearchResponseWrapper typecode = ActorSearchResponse(name='ActorSearchRequestResponse', ns='http://soap.amazon.com') File "AmazonSearch_services.py", line 3011, in __init__ self._return = ProductInfo_Def() File "/var/lib/zope/Products/ProductTool/AmazonSearch_services_types.py", line 1857, in __init__ TClist = [ZSI.TC.String(pname="TotalResults",aname="_TotalResults", optional=1), ZSI.TC.String(pname="TotalPages",aname="_TotalPages", optional=1), ZSI.TC.String(pname="ListName",aname="_ListName", optional=1), DetailsArray_Def(name="Details", ns=ns, optional=1), ] File "/var/lib/zope/Products/ProductTool/AmazonSearch_services_types.py", line 1308, in __init__ ZSI.TCcompound.Array.__init__(self, 'arrayTypeNS:Details[]', Details_Def(name=None,typed=0), pname=name, aname='_%s' % name, oname='%s xmlns:arrayTypeNS="http://soap.amazon.com"' % name, **kw) File "/var/lib/zope/Products/ProductTool/AmazonSearch_services_types.py", line 1791, in __init__ aname=aname, oname=oname,
this is a extension class problem try to get the __init__ of the superclass via __dict__ instead of: ZSI.TCcompound.Array.__init__(self,...) use: ZSI.TCcompound.Array.__dict__['__init__'](self,...)
File "/usr/lib/python2.3/site-packages/ZSI/TCcompound.py", line 65, in __init__ raise TypeError('pyclass must be None or a class, not ' + TypeError: pyclass must be None or a class, not <extension class ExtensionClass at f6be67c0>
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Thanks Bernard. Finally figured it out... Check out http://plone.org/documentation/howto/import-soap-client-object for details On Sun, Jan 16, 2005 at 11:45:48AM +0100, Bernd Dorn wrote:
davelists2@peoplemerge.com wrote:
On Sat, Jan 15, 2005 at 10:40:30AM +0100, Bernd Dorn wrote:
Aclass needs to be inherited from Acquisition.Explcitit or Implicit and and in myTool: def getAclass(self): inter = [base.Aclass().__of__(self),] return inter
I can post more code if necessary, but:
Somehow, having already inherited from ZSI.TCcompound.Struct, I cannot also inherit from Acquisition.Explicit:
Traceback (most recent call last): File "<string>", line 1, in ? File "/usr/lib/zope/lib/python/Zope/__init__.py", line 51, in app startup() File "/usr/lib/zope/lib/python/Zope/__init__.py", line 47, in startup _startup() File "/usr/lib/zope/lib/python/Zope/App/startup.py", line 45, in startup OFS.Application.import_products() File "/usr/lib/zope/lib/python/OFS/Application.py", line 637, in import_products import_product(product_dir, product_name, raise_exc=debug_mode) File "/usr/lib/zope/lib/python/OFS/Application.py", line 660, in import_product product=__import__(pname, global_dict, global_dict, silly) File "/var/lib/zope/Products/ProductTool/__init__.py", line 2, in ? from Products.ProductTool import ProductGhost,AmazonProduct File "/var/lib/zope/Products/ProductTool/AmazonProduct.py", line 7, in ? from AmazonSearch_services import * File "AmazonSearch_services.py", line 3020, in ? class ActorSearchResponseWrapper(ActorSearchResponse): File "AmazonSearch_services.py", line 3023, in ActorSearchResponseWrapper typecode = ActorSearchResponse(name='ActorSearchRequestResponse', ns='http://soap.amazon.com') File "AmazonSearch_services.py", line 3011, in __init__ self._return = ProductInfo_Def() File "/var/lib/zope/Products/ProductTool/AmazonSearch_services_types.py", line 1857, in __init__ TClist = [ZSI.TC.String(pname="TotalResults",aname="_TotalResults", optional=1), ZSI.TC.String(pname="TotalPages",aname="_TotalPages", optional=1), ZSI.TC.String(pname="ListName",aname="_ListName", optional=1), DetailsArray_Def(name="Details", ns=ns, optional=1), ] File "/var/lib/zope/Products/ProductTool/AmazonSearch_services_types.py", line 1308, in __init__ ZSI.TCcompound.Array.__init__(self, 'arrayTypeNS:Details[]', Details_Def(name=None,typed=0), pname=name, aname='_%s' % name, oname='%s xmlns:arrayTypeNS="http://soap.amazon.com"' % name, **kw) File "/var/lib/zope/Products/ProductTool/AmazonSearch_services_types.py", line 1791, in __init__ aname=aname, oname=oname,
this is a extension class problem
try to get the __init__ of the superclass via __dict__
instead of:
ZSI.TCcompound.Array.__init__(self,...)
use:
ZSI.TCcompound.Array.__dict__['__init__'](self,...)
File "/usr/lib/python2.3/site-packages/ZSI/TCcompound.py", line 65, in __init__ raise TypeError('pyclass must be None or a class, not ' + TypeError: pyclass must be None or a class, not <extension class ExtensionClass at f6be67c0>
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
participants (2)
-
Bernd Dorn -
davelists2@peoplemerge.com