Thanks for the reply, but the Name error is in the UserFileFolder_add method when it is calling UserFileFolder.createInObjectManager. Any how, all I really wanted is was a WORKING example of how to add a ZClass to a folder in Python Script? Nothing more? Your website link did not work, either. Thanks, Chris -----Original Message----- From: Dieter Maurer [mailto:dieter@handshake.de] Sent: Friday, February 15, 2002 3:03 PM To: Chris Bruce Cc: zope@zope.org Subject: Re: [Zope] Python Script Question Chris Bruce writes:
Can any one give me a working example of how to add a ZCLASS to a folder in Python Script? I have tried:
request = context.REQUEST
for i in context.Users.UserFolders.objectValues():
folder.manage_addProduct["UserFileFolder"].UserFileFolder_add(id=i.id)
print context.REQUEST["id"]
return printed
But it is giving me the following error: Traceback (innermost last): ... (Object: UserFileFolder.createInObjectManager(REQUEST['id'], REQUEST)) (Info: REQUEST) File <string>, line 2, in f (Object: guarded_getitem) NameError: (see above)
Zope error messages are better than the quotations I often see in the mailing list. It tells you which name is not found! As you surely understand this is an essential information. From your code above, I would expect "folder" is unknown. But that's probably because your just forgot to show us the definition of "folder"... The traceback suggests, "id" is unknown in "REQUEST". I expect that this is due to the fact, that "UserFileFolder_add" is a DTML method that is called wrongly (without the necessary 2 positional parameters). If this analysis is correct, then you should read the section "Calling DTML objects" in <http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html> For the future: When you report tracebacks, you should report "Error Type" and "Error Value", too. Dieter _______________________________________________ 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 )