[Zope] Learning Zope, Question re ZODB, classes

Dieter Maurer dieter@handshake.de
Mon, 23 Jun 2003 19:14:47 +0200


Jeff Childers wrote at 2003-6-23 08:19 -0400:
 > ...
 > I grok the DTML and am thinking I need to be looking more at ZPT, but I can 
 > muddle my way through either of those. Here's where I'm stuck: now that 
 > I've created my "objects" (folders), how do I address them from Python 
 > scripts for add/edit/delete functionality? I can see in the sample apps how 
 > to p_changed=1 to save the current object, but how about a new one? I can't 
 > save my object if I don't have one yet....

You create new objects by:

    someObjectManager.manage_addProduct[ProductName].constructor(args...)

"someObjectManager" is the destination where the new objects should be
created in. Usually, it is a Folder.

"ProductName" is the name of the product that defines the class
that should be instantiated. It is 'OFSP' for many Zope builtin
classes (e.g. "Folder", "DTMLMethod"). PythonScripts and
PageTemplates live in their own product, however.

"constructor" is the constructor to create instances of your class.
It is (e.g.) "manage_addFolder" to create a folder and "manage_addFile"
to create a file. Look for "registerClass" in the products "__init__.py".


Dieter