[Zope] Programatically Adding 3rd Party Products?
Paul Winkler
pw_lists@slinkp.com
Thu, 31 Jul 2003 11:41:48 -0400
On Thu, Jul 31, 2003 at 08:42:47AM -0600, Edward Pollard wrote:
> For those our there in the audience keeping score (and for the poor
> schmuck who searches the list archive for the answer to the same
> question):
>
> The answer is
> manage_addProduct['VarImage'].manage_addVarImage(imagename, imagedata)
>
> Where
> manage_addProduct[productname].productconstructor(parameters)
> is the general form.
Yes indeed... fwiw, this is mentioned in the 2.6 edition of the
Zope Book. Maybe not easy to find, but it's there, in the
"advanced scripting" chapter:
"""
Add a new object to the context
Scripts can add objects to folders, just like you do in the Zope
management interface. The context has to be a folderish object
(i.e. a folder or another object derived from ObjectManager).
The general pattern is:
context.manage_addProduct['PackageName'].manage_addProductName(id)
manage_addProduct is a mapping in which we can look up a dispatcher -
an object which gives us the necessary factory for creating a new
object in the context. For most of the built-in Zope classes, the
PackageName is OFSP, and the factory method is named after the product
class itself. Once you have the factory method, you must pass it
whatever arguments are needed for adding an object of this type.
Some examples will make this clear.
...
"""
I highly recommend re-reading that chapter (and the rest of the book)
every now and then - even though I co-edited the chapter I still forget
things and have to look them up again :-)
--
Paul Winkler
http://www.slinkp.com
Look! Up in the sky! It's HAPPY ARNOLD OCEAN!
(random hero from isometric.spaceninja.com)