AttributeError: LazyMap instance has no attribute '_product'
I have a Zope 2.8.8 for which I've developed a product that creates an object called Collection that is defined like this:: class Collection(BTreeFolder2, CatalogAware): implements(ICollection) meta_type = COLLECTION_METATYPE def __init__(self, id, **other_stuff): apply(BTreeFolder2.__init__, (self, id), {}) # set other_stuff When in the ZMI, if I try to create an object (eg. Image) using the dropdown I get 404 with: Cannot locate object at: http://localhost:8080/Site/collectionA/manage_addProduct/OFSP If I try to do it in code like this:: def _uploadPhoto(self, file): adder = self.manage_addProduct['Photo'].manage_addPhoto adder('photo', '', file, **photo_settings) Then I get this error:: ... File "/home/peterbe/zope/zope288/Products/Mest/ProductPhotoBase.py", line 122, in uploadPhoto self._addProductPhoto(photo_id, unicodify(comment).strip(), photofile) File "/home/peterbe/zope/zope288/Products/Mest/ProductPhotoBase.py", line 130, in _addProductPhoto photo_adder = self.manage_addProduct['Photo'].manage_addPhoto File "/home/peterbe/zope/zope288/lib/python/App/FactoryDispatcher.py", line 26, in __getitem__ return self.__bobo_traverse__(None, name) File "/home/peterbe/zope/zope288/lib/python/App/FactoryDispatcher.py", line 29, in __bobo_traverse__ product=self.aq_acquire('_getProducts')()._product(name) AttributeError: LazyMap instance has no attribute '_product' Any idea anyone? PS. I've enpseudo coded the code a bit to explain the problem clearer. -- Peter Bengtsson, work www.fry-it.com home www.peterbe.com hobby www.issuetrackerproduct.com
Peter Bengtsson wrote at 2006-12-4 11:52 +0000:
... If I try to do it in code like this::
def _uploadPhoto(self, file): adder = self.manage_addProduct['Photo'].manage_addPhoto adder('photo', '', file, **photo_settings)
Then I get this error::
... File "/home/peterbe/zope/zope288/Products/Mest/ProductPhotoBase.py", line 122, in uploadPhoto self._addProductPhoto(photo_id, unicodify(comment).strip(), photofile) File "/home/peterbe/zope/zope288/Products/Mest/ProductPhotoBase.py", line 130, in _addProductPhoto photo_adder = self.manage_addProduct['Photo'].manage_addPhoto File "/home/peterbe/zope/zope288/lib/python/App/FactoryDispatcher.py", line 26, in __getitem__ return self.__bobo_traverse__(None, name) File "/home/peterbe/zope/zope288/lib/python/App/FactoryDispatcher.py", line 29, in __bobo_traverse__ product=self.aq_acquire('_getProducts')()._product(name) AttributeError: LazyMap instance has no attribute '_product'
Apparently, something at or above your "Collection" instance defines a "_getProducts" -- as something to return a catalog search result. Now, "_getProducts" is assumed to be provided by the Zope application object and not by any intermediate instance. As you see, Zope's product accessing breaks when this requirement is violated. Identify the "_getProducts" and rename it. -- Dieter
Dieter Maurer wrote:
Peter Bengtsson wrote at 2006-12-4 11:52 +0000: ...
File "/home/peterbe/zope/zope288/Products/Mest/ProductPhotoBase.py", line 130, in _addProductPhoto photo_adder = self.manage_addProduct['Photo'].manage_addPhoto File "/home/peterbe/zope/zope288/lib/python/App/FactoryDispatcher.py", line 26, in __getitem__ return self.__bobo_traverse__(None, name) File "/home/peterbe/zope/zope288/lib/python/App/FactoryDispatcher.py", line 29, in __bobo_traverse__ product=self.aq_acquire('_getProducts')()._product(name) AttributeError: LazyMap instance has no attribute '_product'
Apparently, something at or above your "Collection" instance defines a "_getProducts" -- as something to return a catalog search result.
Now, "_getProducts" is assumed to be provided by the Zope application object and not by any intermediate instance. As you see, Zope's product accessing breaks when this requirement is violated.
Identify the "_getProducts" and rename it.
You're right!! I do. I have a method called exactly that which returns products as in purchasable products. Thanks a million! You're a star! -- Peter Bengtsson, work www.fry-it.com home www.peterbe.com hobby www.issuetrackerproduct.com
participants (2)
-
Dieter Maurer -
Peter Bengtsson