the usual incantation for creating an instance of a product is folderishobject.manage_addProduct['product name'].manageaddXXXXX( ...) I want to create programmatic instances of the ZUBB product which has a meta_type of 'ZUBB Folder' confirmed by looking at the code. The product seems to be properly installed, appears in the dropdown menu, and creates instances through the ZMI. But, the following script fails: request = container.REQUEST RESPONSE = request.RESPONSE # add in an instance of the ZUBB product # we work here obj = container.restrictedTraverse('/agilediscussions') print obj print d_id, d_title p = obj.manage_addProduct print p p = obj.manage_addProduct['ZUBB Folder'] print p #p = p.mange_addZUBBFolder #print p #p(id=d_id, title=d_title) return printed with Traceback (innermost last): Module ZPublisher.Publish, line 98, in publish Module ZPublisher.mapply, line 88, in mapply Module ZPublisher.Publish, line 39, in call_object Module Shared.DC.Scripts.Bindings, line 252, in __call__ Module Shared.DC.Scripts.Bindings, line 283, in _bindAndExec Module Products.PythonScripts.PythonScript, line 314, in _exec Module Script (Python), line 10, in createDiscussion - <PythonScript at /agilediscussions/createDiscussion> - Line 10 Module AccessControl.ZopeGuards, line 90, in guarded_getitem Module App.FactoryDispatcher, line 26, in __getitem__ Module App.FactoryDispatcher, line 29, in __bobo_traverse__ Module App.Product, line 66, in _product AttributeError: ZUBB Folder What's can be the problem? -d
I'm not really sure where the name got reset, but using 'ZUBB" as the name to the object manager seems to work. Is some transormation made on the meta-type before it's used as a key for the ObjectManager table? On Sat, 19 Jul 2003, Dennis Allison wrote:
the usual incantation for creating an instance of a product is
folderishobject.manage_addProduct['product name'].manageaddXXXXX( ...)
I want to create programmatic instances of the ZUBB product which has a meta_type of 'ZUBB Folder' confirmed by looking at the code.
[snip]
Dennis Allison wrote:
I'm not really sure where the name got reset, but using 'ZUBB" as the name to the object manager seems to work.
Is some transormation made on the meta-type before it's used as a key for the ObjectManager table?
The manage_addProduct['product name'] usen take a meta_type but the name of the Product. This can be misleading sometimes because many product classes have the same meta_type as their product. So the product name in this case is "ZUBB"? And the mange_addZUBBFolder is the factory method who knows how to create a object of a class that probably have the meta_type 'ZUBB Folder'. In theory the factory method could create anything, even create several object with different meta_types at ones. Cheers, Johan Carlsson -- Johan Carlsson Tel: + 46 8 31 24 94 Colliberty Mob: + 46 70 558 25 24 Torsgatan 72 Email: johanc@easypublisher.com SE-113 37 STOCKHOLM
participants (2)
-
Dennis Allison -
Johan Carlsson