[Zope] Python Script Question
Dieter Maurer
dieter@handshake.de
Sat, 16 Feb 2002 00:03:19 +0100
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