DTML method --> PythonScript
Hi everyone, I recently asked what the following DTML Method would look like as a PythonScript. Unfortunately, the answer given doesn't work. I've including the traceback below, and would appreciate any further ideas anyone has. Original SchoolMenuClass_add DTML Method: <HTML> <HEAD><TITLE>Add SchoolMenuClass</TITLE></HEAD> <BODY BGCOLOR="#FFFFFF" LINK="#000099" VLINK="#555555"> <dtml-with "SchoolMenuClass.createInObjectManager(REQUEST['id'], REQUEST)"> <dtml-call "propertysheets.Basic.manage_editProperties(REQUEST)"> <dtml-call reindex_object> </dtml-with> <dtml-if DestinationURL> <dtml-call "RESPONSE.redirect(DestinationURL+'/manage_workspace')"> <dtml-else> <dtml-call "RESPONSE.redirect(URL2+'/manage_workspace')"> </dtml-if> </body></html> The PythonScript that was suggested (with REQUEST and RESPONSE passed in the parameter list): REQUEST = context.REQUEST RESPONSE = REQUEST.RESPONSE schoolmenu = SchoolMenuClass.createInObjectManager(REQUEST['id'], REQUEST) schoolmenu.propertysheets.Basic.manage_editProperties(REQUEST) schoolmenu.reindex_object() if REQUEST.has_key(DestinationURL): return RESPONSE.redirect(DestinationURL+'/manage_workspace') return RESPONSE.redirect(URL2+'/manage_workspace') The resulting traceback: <!-- Traceback (innermost last): File /var/lib/zope/2.3.0/lib/python/ZPublisher/Publish.py, line 222, in publish_module File /var/lib/zope/2.3.0/lib/python/ZPublisher/Publish.py, line 187, in publish File /var/lib/zope/2.3.0/lib/python/Zope/__init__.py, line 221, in zpublisher_exception_hook (Object: RoleManager) File /var/lib/zope/2.3.0/lib/python/ZPublisher/Publish.py, line 171, in publish File /var/lib/zope/2.3.0/lib/python/ZPublisher/mapply.py, line 160, in mapply (Object: SchoolMenuClass_add) File /var/lib/zope/2.3.0/lib/python/ZPublisher/Publish.py, line 112, in call_object (Object: SchoolMenuClass_add) File /var/lib/zope/2.3.0/lib/python/Shared/DC/Scripts/Bindings.py, line 324, in __call__ (Object: SchoolMenuClass_add) File /var/lib/zope/2.3.0/lib/python/Shared/DC/Scripts/Bindings.py, line 353, in _bindAndExec (Object: SchoolMenuClass_add) File /var/lib/zope/2.3.0/lib/python/Products/PythonScripts/PythonScript.py, line 330, in _exec (Object: SchoolMenuClass_add) (Info: ({'script': <PythonScript instance at 9e222a0>, 'context': <Factory instance at aa67c18>, 'container': <FactoryDispatcher instance at 95db5c8>, 'traverse_subpath': []}, (<h3>form</h3><table><tr valign="top" align="left"><th>id</th><td>'test2'</td></tr><tr valign="top" align="left"><th>menu_date</th><td>DateTime('2001/05/01')</td></tr><tr rest of REQUEST snipped... File Script (Python), line 4, in SchoolMenuClass_add NameError: SchoolMenuClass --> -Tim -- Tim Wilson | Visit Sibley online: | Check out: Henry Sibley HS | http://www.isd197.k12.mn.us/ | http://www.zope.org/ W. St. Paul, MN | | http://slashdot.org/ wilson@visi.com | <dtml-var pithy_quote> | http://linux.com/
From: Timothy Wilson <wilson@visi.com>
schoolmenu = SchoolMenuClass.createInObjectManager(REQUEST['id'], REQUEST) schoolmenu.propertysheets.Basic.manage_editProperties(REQUEST) schoolmenu.reindex_object()
if REQUEST.has_key(DestinationURL): return RESPONSE.redirect(DestinationURL+'/manage_workspace') return RESPONSE.redirect(URL2+'/manage_workspace')
This has a few problems. Try this (tested): REQUEST = container.REQUEST schoolmenu = container.SchoolMenuClass.createInObjectManager(REQUEST['id'], REQUEST) schoolmenu.propertysheets.Basic.manage_editProperties(REQUEST) schoolmenu.reindex_object() RESPONSE = REQUEST.RESPONSE if REQUEST.has_key('DestinationURL'): return RESPONSE.redirect(REQUEST['DestinationURL']+'/manage_workspace') return RESPONSE.redirect(REQUEST['URL2']+'/manage_workspace') Cheers, Evan @ digicool & 4-am
participants (2)
-
Evan Simpson -
Timothy Wilson