[Zope] ZClasses meet PythonScripts, sample request
Timothy Wilson
wilson@visi.com
Mon, 15 Jan 2001 10:18:15 -0600 (CST)
Jim (or anyone else who's feeling charitable this morning),
Thanks for all your help. I really appreciate it. I wonder if you'd have
time to look one more time at the two methods I've got that aren't
working. I've included the actual code for my job posting product. Perhaps
someone will find it instructive. I have a feeling that the remaining
problem is not directly related to the processing of the form by the
PythonScript. I also included the traceback at the end of this message.
Here are the two methods. I have a table that displays the currently
available jobs and displays two little icons which call the edit or delete
methods on the corresponding instance of the 'Job Posting' class. The edit
icon links to the 'editJobForm' method which in turn calls the
'editFormAction' method that actually processing the change.
------------------
editJobForm
-----------------
<dtml-var standard_html_header>
<h2>Edit a Job Board Entry</h2>
<p>This form allows you to make changes to current postings on the online
job board. You don't needed to fill in every
field on the form. Click on the "Submit Edits" button at the bottom of the
screen to save your changes to the database.</p>
<dtml-if "REQUEST.form.has_key('editJob')">
<dtml-call "editFormAction(REQUEST)">
<p><font color="red">Your changes have been saved</font></p>
</dtml-if>
<form action="editJobForm">
<table border="0">
<tr><th>Notes</th>
<td><textarea name="notes:text" rows="10" cols="60" wrap="virtual"><dtml-var
notes></textarea></td>
</tr>
<tr><th>Job ID</th>
<td><input type="text" name="id" size="20" value="<dtml-var id>"></td>
</tr>
<tr><th>Organization</th>
<td><input type="text" name="organization" size="60" value="<dtml-var
org_name>"></td>
</tr>
<tr><th>Position</th>
<td><input type="text" name="position" size="60" value="<dtml-var
name>"></td>
</tr>
<tr><th>Description</th>
<td><textarea
name="description:text" rows="10" cols="60" wrap="virtual"><dtml-var
description></textarea></td>
</tr>
<tr><th>Pay Offered</th>
<td><input type="text" name="pay" size="60" value="<dtml-var pay>"></td>
</tr>
<tr><th>Line of Authority</th>
<td><input type="text" name="loa" size="60" value="<dtml-var loa>"></td>
</tr>
<tr><th>Function</th>
<td><textarea
name="function:text" rows="4" cols="60" wrap="virtual"><dtml-var
function></textarea></td>
</tr>
<tr><th>Qualifications</th>
<td><textarea
name="qualifications:text" rows="8" cols="60" wrap="virtual"><dtml-var
qualifications></textarea></td>
</tr>
<tr>
<td colspan=2>
<p>To create a bullet list of "duties," type each one in the box below and
press the "ENTER" key
between each item in the list.</p>
</td>
</tr>
<tr><th>Duties</th>
<dtml-if duties>
<td><textarea name="duties:list" rows="10" cols="60" wrap="virtual"><dtml-in
duties><dtml-let item=sequence-item><dtml-if item>
<dtml-var item>
</dtml-if></dtml-let></dtml-in></textarea></td>
<dtml-else>
<td><textarea
name="duties:list" rows="10" cols="60" wrap="virtual"></textarea></td>
</dtml-if>
</tr>
<tr><th>Offer Expires</th>
<td><input type="text" name="expires" size="20" value="<dtml-var
offer_expires fmt="%m/%d/%Y">"></td>
</tr>
<tr>
<td colspan=2><p>Enter the date that the job was officially posted.</p></td>
</tr>
<tr><th>Posted Date</th>
<td><input type="text" name="posted" size="20" value="<dtml-var date_posted
fmt="%m/%d/%Y">"></td>
</tr>
<tr>
<td> </td>
<td>
<input type="submit" name="editJob" value=" Submit Edits ">
</form>
<form action="admin_html">
<input type="submit" value=" Cancel ">
</form>
</td>
</tr>
</table>
<dtml-var standard_html_footer>
-----------------
editFormAction (with REQUEST as a parameter)
-----------------
container.propertysheets['job_info'].manage_changeProperties(REQUEST)
The error I get is:
Error Type: TypeError
Error Value: sequence index must be integer
Traceback:
Traceback (innermost last):
File /var/lib/zope/2.3.0a2/lib/python/ZPublisher/Publish.py, line 222, in
publish_module
File /var/lib/zope/2.3.0a2/lib/python/ZPublisher/Publish.py, line 187, in
publish
File /var/lib/zope/2.3.0a2/lib/python/Zope/__init__.py, line 221, in
zpublisher_exception_hook
(Object: Traversable)
File /var/lib/zope/2.3.0a2/lib/python/ZPublisher/Publish.py, line 171, in
publish
File /var/lib/zope/2.3.0a2/lib/python/ZPublisher/mapply.py, line 160, in
mapply
(Object: editJobForm)
File /var/lib/zope/2.3.0a2/lib/python/ZPublisher/Publish.py, line 112, in
call_object
(Object: editJobForm)
File /var/lib/zope/2.3.0a2/lib/python/OFS/DTMLMethod.py, line 189, in
__call__
(Object: editJobForm)
File /var/lib/zope/2.3.0a2/lib/python/DocumentTemplate/DT_String.py, line
538, in __call__
(Object: editJobForm)
File /var/lib/zope/2.3.0a2/lib/python/DocumentTemplate/DT_Util.py, line
336, in eval
(Object: editFormAction(REQUEST))
(Info: REQUEST)
File <string>, line 0, in ?
File /var/lib/zope/2.3.0a2/lib/python/Shared/DC/Scripts/Bindings.py, line
325, in __call__
(Object: editFormAction)
File /var/lib/zope/2.3.0a2/lib/python/Shared/DC/Scripts/Bindings.py, line
354, in _bindAndExec
(Object: editFormAction)
File
/var/lib/zope/2.3.0a2/lib/python/Products/PythonScripts/PythonScript.py,
line 321, in _exec
(Object: editFormAction)
(Info: ({'script': <PythonScript instance at 8826790>,
'context': <JobPosting instance at 871e068>, 'container': <Folder
instance at 885a3e0>, 'traverse_subpath': []},
(<h3>form</h3><table><tr
valign="top" align="left"><th>posted</th><td>'01/14/2001'</td></tr><tr
valign="top" align="left"><th>duties</th><td>['asdfasdf\015\012']</td></tr><tr
-- I've deleted what looks like the entire contents of REQUEST --
File Python Script, line 2, in editFormAction
File /var/lib/zope/2.3.0a2/lib/python/Products/PythonScripts/Guarded.py,
line 276, in __getitem__
File /var/lib/zope/2.3.0a2/lib/python/OFS/PropertySheets.py, line 647, in
__getitem__
(Object: Traversable)
TypeError: (see above)
-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/