[Zope] DTML method --> PythonScript
Mayers, Philip J
p.mayers@ic.ac.uk
Fri, 16 Mar 2001 10:44:24 -0000
REQUEST = context.REQUEST
RESPONSE = REQUEST.RESPONSE
schoolmenu = context.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')
Possibly?
Regards,
Phil
+----------------------------------+
| Phil Mayers, Network Support |
| Centre for Computing Services |
| Imperial College |
+----------------------------------+
-----Original Message-----
From: Timothy Wilson [mailto:wilson@visi.com]
Sent: 13 March 2001 03:08
To: Zope listserv
Subject: [Zope] 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/
_______________________________________________
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 )