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): File /usr/local/www/Zope-2.4/lib/python/ZPublisher/Publish.py, line 223, in publish_module File /usr/local/www/Zope-2.4/lib/python/ZPublisher/Publish.py, line 187, in publish File /usr/local/www/Zope-2.4/lib/python/Zope/__init__.py, line 226, in zpublisher_exception_hook (Object: UserFolders1) File /usr/local/www/Zope-2.4/lib/python/ZPublisher/Publish.py, line 171, in publish File /usr/local/www/Zope-2.4/lib/python/ZPublisher/mapply.py, line 160, in mapply (Object: copyUserFolders) File /usr/local/www/Zope-2.4/lib/python/ZPublisher/Publish.py, line 112, in call_object (Object: copyUserFolders) File /usr/local/www/Zope-2.4/lib/python/Shared/DC/Scripts/Bindings.py, line 324, in __call__ (Object: copyUserFolders) File /usr/local/www/Zope-2.4/lib/python/Shared/DC/Scripts/Bindings.py, line 354, in _bindAndExec (Object: copyUserFolders) File /usr/local/www/Zope-2.4/lib/python/Products/PythonScripts/PythonScript.py, line 363, in _exec (Object: copyUserFolders) (Info: ({'script': <PythonScript instance at 8d0d620>, 'context': <Folder instance at 8bcc280>, 'container': <Folder instance at 8bcc280>, '_': <TemplateDict object at 0x8b3c0e0>, 'traverse_subpath': []}, (), {}, None)) File Script (Python), line 5, in copyUserFolders (Object: guarded_getitem) File /usr/local/www/Zope-2.4/lib/python/OFS/DTMLMethod.py, line 192, in __call__ (Object: UserFileFolder_add) File /usr/local/www/Zope-2.4/lib/python/DocumentTemplate/DT_String.py, line 546, in __call__ (Object: UserFileFolder_add) File /usr/local/www/Zope-2.4/lib/python/DocumentTemplate/DT_With.py, line 133, in render (Object: UserFileFolder.createInObjectManager(REQUEST['id'], REQUEST)) File /usr/local/www/Zope-2.4/lib/python/DocumentTemplate/DT_Util.py, line 231, in eval (Object: UserFileFolder.createInObjectManager(REQUEST['id'], REQUEST)) (Info: REQUEST) File <string>, line 2, in f (Object: guarded_getitem) NameError: (see above) __________________________________________________ Do You Yahoo!? Got something to say? Say it better with Yahoo! Video Mail http://mail.yahoo.com
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
participants (2)
-
Chris Bruce -
Dieter Maurer