[Zope-dev] problem adding ZClass instances via DTML

Mark James Adams mja27@cornell.edu
Tue, 26 Feb 2002 14:25:21 -0500


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
mark@raysend.com | mja27@cornell.edu