RE: [Zope] Newbie ZClass confusion
The following is a python constructor that I usually use. I call this constructor from an html form that sets all of the new object's properties. notice the 'ProductName' and 'ZClassName' (fill those in). --------------------------------------------------------------- #board=context.manage_clone(container.messageBoardTemplate, id) board=context.manage_addProduct['ProductName'].ZClassName.createInObjectMana ger(REQUEST['id'], REQUEST) board.propertysheets.common.manage_editProperties(REQUEST) if REQUEST is not None: try: u=context.DestinationURL() except: u=REQUEST['URL1'] REQUEST.RESPONSE.redirect(u+'/manage_main?update_menu=1') ------------------------------------------------------------ This will create a new object of the class you specified in the folder you called it from. -----Original Message----- From: Patrick Stinson [mailto:ajole-1@gci.net] Sent: Tuesday, December 03, 2002 1:14 PM To: toman Subject: RE: [Zope] Newbie ZClass confusion The following is a python constructor that I usually use. I call this constructor from an html form that sets all of the new object's properties. notice the 'ProductName' and 'ZClassName' (fill those in). --------------------------------------------------------------- #board=context.manage_clone(container.messageBoardTemplate, id) board=context.manage_addProduct['ProductName'].ZClassName.createInObjectMana ger(REQUEST['id'], REQUEST) board.propertysheets.common.manage_editProperties(REQUEST) if REQUEST is not None: try: u=context.DestinationURL() except: u=REQUEST['URL1'] REQUEST.RESPONSE.redirect(u+'/manage_main?update_menu=1') ------------------------------------------------------------ This will create a new object of the class you specified in the folder you called it from. -----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of toman Sent: Wednesday, December 04, 2002 12:59 AM To: zope@zope.org Subject: [Zope] Newbie ZClass confusion Hi, I'm a little confused about ZClass construction. I have a product 'Lucy' which has folderish ZClasses 'bob' and 'bill' in it. Each instance of a bob should be constructed with a bill named 'Willliam' in it. The default DTML method bob_add has the following snippet: <dtml-with "bob.createInObjectManager(REQUEST['id'], REQUEST)"> <dtml-comment> ... </dtml-comment> </dtml-with> Where and how do I construct the bill ? My naive thought was to put a <dtml-call "bill_add(id='William')"> in the dtml-with statement, but that doesn't seem to work. Suggestions? I've read 'The Zope Book' a couple times, looked through ZopeLabs and didn't see anything like this except for adding a folder, which isn't that helpful because they're a standard class and have various management methods defined for them. Ideas? J. Toman _______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Patrick Stinson wrote:
The following is a python constructor that I usually use. I call this constructor from an html form that sets all of the new object's properties. notice the 'ProductName' and 'ZClassName' (fill those in).
Thanks. I modified it slightly and it works fine. A few questions if I might: manage_addProduct['ProductName'] This is a dictionary of products ? createInObjectManager(REQUEST['id'], REQUEST) Is this method documented somewhere? Thanks again, J. Toman
joseph toman writes:
The following is a python constructor that I usually use. I call this constructor from an html form that sets all of the new object's properties. notice the 'ProductName' and 'ZClassName' (fill those in).
Thanks. I modified it slightly and it works fine. A few questions if I might:
manage_addProduct['ProductName']
This is a dictionary of products ? No, "manage_addProduct" returns a "ProductDispatcher" instance (class defined in the "App" package). However, it defines a partial mapping API (it defines "__getitem__", therefore, you can access it via "[...]").
createInObjectManager(REQUEST['id'], REQUEST)
Is this method documented somewhere? It is a ZClass method ("ZClasses.ZClass.ZClass"). There is a little source code documentation for its definition (a so called "DocString").
Dieter
participants (3)
-
Dieter Maurer -
joseph toman -
Patrick Stinson