Re: [Zope-dev] problem adding ZClass instances via DTML

2002-02-26 Thread Gilles Lenfant

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/taz/addZClasses), but 
: Zope always returns an error.
: 
: Using the code from a DTMLMethod in another ZClass in the same product:
: 
: 
: 
: 
: 
: 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:
: 
: 
: 
: 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 )



Re: [Zope-dev] problem adding ZClass instances via DTML

2002-02-26 Thread Dieter Maurer

Mark James Adams writes:
 > I'm following the instructions in "Adding ZClass Instances 
 > Programmatically" (http://www.zope.org/Members/taz/addZClasses), but 
 > Zope always returns an error.
 > 
 > Using the code from a DTMLMethod in another ZClass in the same product:
 > 
 > 
 > 
 > 
Where is the second positional argument for DTML objects?

Please read "Calling DTML objects" in

  

to avoid such errors in the future.


Dieter

___
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 )