Mark, It seems you forget the id of your new object !! I use do do it in Python script (easier for testing initial data from request). But you can translate in DTML if you prefer... # Test initial data from REQUEST and redirect somewhere if required ... # Create the new ZClass based object newobject = somefolderishobject.manage_addProduct['MyProduct'].MyZClass.createInObjectManager(newId, context.REQUEST) # May add computed values to properties props = {} props['created'] = DateTime() props['creator'] = context.REQUEST.AUTHENTICATED_USER.getUserName() ... newobject.propertysheets.mypropertysheet.manage_changeProperties(props) # Redirect somewhere or return the object or whatever
HTH --Gilles ----- Original Message ----- From: "Mark James Adams" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, February 26, 2002 8:25 PM Subject: [Zope-dev] problem adding ZClass instances via DTML : I'm following the instructions in "Adding ZClass Instances : Programmatically" (http://www.zope.org/Members/tazzzzz/addZClasses), but : Zope always returns an error. : : Using the code from a DTMLMethod in another ZClass in the same product: : : <dtml-with "manage_addProduct['MyProduct']"> : <dtml-call "MyZClass_add(_.None, NoRedir=1)"> : </dtml-with> : : I get the error: : : File /usr/local/Zope/lib/python/DocumentTemplate/DT_Util.py, line 339, : in eval (Object: MyZClass.createInObjectManager(REQUEST['id'], REQUEST)) : (Info: REQUEST) File , line 0, in ? NameError: MyZClass : : So this is clearly having a problem finding MyZClass from the : MyZClass_add method. : : I then noticed that, according to the HowTo, if you are instantiating a : ZClass from within another ZClass, you only need the code: : : <dtml-call "MyZClass_add(_.None, NoRedir=1)"> : : However, this gives the error: : : File /usr/local/Zope/lib/python/DocumentTemplate/DT_Util.py, line 339, : in eval (Object: MyZClass_add(_.None, NoRedir=1)) (Info: _) File , line : 0, in ? NameError: MyZClass_add : : Any suggestions? : : Thanks. : : -- : Mark James Adams : [EMAIL PROTECTED] | [EMAIL PROTECTED] : : : : _______________________________________________ : Zope-Dev maillist - [EMAIL PROTECTED] : http://lists.zope.org/mailman/listinfo/zope-dev : ** No cross posts or HTML encoding! ** : (Related lists - : http://lists.zope.org/mailman/listinfo/zope-announce : http://lists.zope.org/mailman/listinfo/zope ) : _______________________________________________ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )