Learning Zope, Question re ZODB, classes
Hi all, I'm trying to build a simple contact manager app with Zope as a learning exercise. Companies, contacts, events. So: I created three folders, one for Companies, one for Contacts, one for Events. I added properties to each folder relevant to the type of object (e.g. cmp_name, cmp_address, con_firstname, con_lastname). 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.... Any advice would be GREATLY appreciated. Even if just a pointer to a sample product that illustrated add/edit/delete functionality... TIA, Jeff
Jeff Childers wrote:
So: I created three folders, one for Companies, one for Contacts, one for Events. I added properties to each folder relevant to the type of object (e.g. cmp_name, cmp_address, con_firstname, con_lastname).
Any advice would be GREATLY appreciated. Even if just a pointer to a sample product that illustrated add/edit/delete functionality...
If you look at the html in the management interface, that should show you how to do it. regards Max M
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
participants (3)
-
Dieter Maurer -
Jeff Childers -
Max M