[Zope] creating instances of ZDiscussions programatically

Dieter Maurer dieter@handshake.de
Fri, 26 Jul 2002 20:57:35 +0200


Dennis Allison writes:
 > I am having difficulty creating instances of ZDiscussions programatically.
 > Creating instances from the ZMI works fine.  But creating instances as an 
 > action and having it work automagically has proven to be a problem. 
Do you already understand how creation from the ZMI works?

  You have a form that collects parameters for the instance.
  The form then calls an action via the Web.
  ZPublisher automatically provides the parameters as needed.

When you want to do this programmatically, you simply call the
action with the correct parameters. It looks like:

       your_destination.manage_addProduct[your_product].the_action(parameters)

"your_destination" is the ObjectManager (usually a folder) where the
new instance shoult be created.
"your_product" is the product which contains your class
(probably "ZDiscussions" in your case).
"the_action" is the action that would also be called by the ZMI.

You need to know which parameters the action expects.
This may be documented. If it is a DTML object, it will
be "client" and "REQUEST". In the above case,
"client" would be "your_destination.manage_addProduct[your_product]"
and "REQUEST" the request object.

When it is a DTML object (which is the default for ZClasses),
then it may be a good idea to look into its definition.
This may show you, how to get a bit leaner and more efficient code.


Dieter