[Zope] Pesky DateTime problem

Timothy Wilson wilson@visi.com
Fri, 15 Dec 2000 16:37:54 -0600 (CST)


Hi everyone,

I would *really* appreciate some advice about a problem with a ZClass I
created. This product is a Job Board that our H.R. department can use to
post openings and the public can view. I began by looking at the very nice
"Build a Searchable Job Board" How-To at
http://www.zope.org/Members/mukhsein/job_board_howto and combined that with
the ZClass approach put forward in the Beehive ZClass documentation.

The problem lies in adding an instance of the job board ZClass at which
point Zope reports an "Invalid Date-Time String". At the risk of providing
too much information, I'm going to include some of the relevant methods and
the traceback. I would love it if someone could spot my error. (Why do I
have this feeling that it's something really simple and that I'm an even
larger moron than my friends and acquaintances assume me to be? :-)

Here the traceback:

<!--
Traceback (innermost last):
  File /var/lib/zope/2.2.2/lib/python/ZPublisher/Publish.py, line 222, in
publish_module
  File /var/lib/zope/2.2.2/lib/python/ZPublisher/Publish.py, line 187, in
publish
  File /var/lib/zope/2.2.2/lib/python/Zope/__init__.py, line 221, in
zpublisher_exception_hook
    (Object: Traversable)
  File /var/lib/zope/2.2.2/lib/python/ZPublisher/Publish.py, line 171, in
publish
  File /var/lib/zope/2.2.2/lib/python/ZPublisher/mapply.py, line 160, in
mapply
    (Object: entry_addProcessor)
  File /var/lib/zope/2.2.2/lib/python/ZPublisher/Publish.py, line 112, in
call_object
    (Object: entry_addProcessor)
  File /var/lib/zope/2.2.2/lib/python/OFS/DTMLMethod.py, line 172, in
__call__
    (Object: entry_addProcessor)
  File /var/lib/zope/2.2.2/lib/python/DocumentTemplate/DT_String.py, line
528, in __call__
    (Object: entry_addProcessor)
  File /var/lib/zope/2.2.2/lib/python/DocumentTemplate/DT_With.py, line 146,
in render
    (Object: manage_addProduct['JobBoard'])
  File /var/lib/zope/2.2.2/lib/python/DocumentTemplate/DT_Util.py, line 337,
in eval
    (Object: job_board_entry_add(_.None,_, NoRedir=1))
    (Info: _)
  File &lt;string&gt;, line 0, in ?
  File /var/lib/zope/2.2.2/lib/python/OFS/DTMLMethod.py, line 168, in
__call__
    (Object: job_board_entry_add)
  File /var/lib/zope/2.2.2/lib/python/DocumentTemplate/DT_String.py, line
528, in __call__
    (Object: job_board_entry_add)
  File /var/lib/zope/2.2.2/lib/python/DocumentTemplate/DT_With.py, line 146,
in render
    (Object: job_board_entry.createInObjectManager(REQUEST['jobID'],
REQUEST))
  File /var/lib/zope/2.2.2/lib/python/DocumentTemplate/DT_Util.py, line 337,
in eval
    (Object: propertysheets.entry_info.manage_editProperties(REQUEST))
    (Info: REQUEST)
  File &lt;string&gt;, line 0, in ?
  File /var/lib/zope/2.2.2/lib/python/OFS/PropertySheets.py, line 459, in
manage_editProperties
    (Object: Traversable)
  File /var/lib/zope/2.2.2/lib/python/OFS/PropertySheets.py, line 286, in
_updateProperty
    (Object: Traversable)
  File /var/lib/zope/2.2.2/lib/python/ZPublisher/Converters.py, line 173, in
field2date
  File /var/lib/zope/2.2.2/lib/python/DateTime/DateTime.py, line 698, in
__init__
Invalid Date-Time String: (see above)

-->

Here's the job_board_entry_add method that lives in
Control_Panel/Products/JobBoard/:

<HTML>
<HEAD><TITLE>Add job_board_entry</TITLE></HEAD>
<BODY BGCOLOR="#FFFFFF" LINK="#000099" VLINK="#555555">

<dtml-with "job_board_entry.createInObjectManager(REQUEST['jobID'],
REQUEST)">
<dtml-call "propertysheets.entry_info.manage_editProperties(REQUEST)">
</dtml-with>

<dtml-if NoRedir>
<dtml-else>
<dtml-if DestinationURL>

<dtml-call "RESPONSE.redirect(DestinationURL+'/manage_workspace')">

<dtml-else>

<dtml-call "RESPONSE.redirect(URL2+'/manage_workspace')">
</dtml-if>
</dtml-if>
</body></html>

Here's the "Add a Job Posting" form that the H.R. people use:

<dtml-var standard_html_header>

<h2>Add a Job Board Entry</h2>
<p>This form will create a new job posting for the online job board. You
don't needed to fill in every 
field on the form. Click on the "Add Entry" button at the bottom of the
screen to add the posting to the database.</p>

<form action="entry_addProcessor">
<table border="0">

<tr><th>Job ID</th>
<td><input type="text" name="new_jobID" size="20"></td>
</tr>
<tr><th>Organization</th>
<td><input type="text" name="new_organization" size="60"></td>
</tr>
<tr><th>Position</th>
<td><input type="text" name="new_position" size="60"></td>
</tr>
<tr><th>Description</th>
<td><textarea
name="new_description:text" rows="10" cols="60" wrap="virtual"></textarea></td>
</tr>
<tr><th>Pay Offered</th>
<td><input type="text" name="new_pay" size="60"></td>
</tr>
<tr><th>Line of Authority</th>
<td><input type="text" name="new_loa" size="60"></td>
</tr>
<tr><th>Function</th>
<td><textarea
name="new_function:text" rows="4" cols="60" wrap="virtual"></textarea></td>
</tr>
<tr><th>Qualifications</th>
<td><textarea
name="new_qualifications:text" rows="8" cols="60" wrap="virtual"></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>
<td><textarea
name="new_duties:text" rows="10" cols="60" wrap="virtual"></textarea></td>
</tr>
<tr><th>Offer Expires</th>
<td><input type="text" name="new_expires:date" size="20"></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="new_posted:date" size="20"></td>
</tr>
<tr>
<td colspan=2><p>Enter any notes you'd like to add. This field will be
invisible to site visitors.</p></td>
</tr>
<tr><th>Notes</th>
<td><textarea
name="new_notes:text" rows="10" cols="60" wrap="virtual"></textarea></td>
<tr>
<td>&nbsp;</td>
<td>
<input type="submit" value=" Add Entry ">
</form>
<form action="admin_html">
<input type="submit" value=" Cancel ">
</form>
</td>
</tr>
</table>

<dtml-var standard_html_footer>

And finally, here's the method that processes that form input. This method
(and the previous form) live in the folder where ZClass instances are
created.

<dtml-var standard_html_header>

<dtml-call "REQUEST.set('jobID', REQUEST.form['new_jobID'])">
<dtml-with "manage_addProduct['JobBoard']">
<dtml-call "job_board_entry_add(_.None,_, NoRedir=1)">
</dtml-with>

<form action="admin_html">
<dtml-in "objectValues(['Job Board Entry'])">
<dtml-if "(_['sequence-item'].id == REQUEST.form['new_jobID'])">
<dtml-call "REQUEST.set('our_job', _['sequence-item'])">
</dtml-if>
</dtml-in>

<dtml-call "_['our_job'].propertysheets.entry_info.manage_changeProperties({
'position_name' : REQUEST.form['new_position'],
'position_description' : REQUEST.form['new_description'],
'position_pay' : REQUEST.form['new_pay'],
'position_loa' : REQUEST.form['new_loa'],
'position_function' : REQUEST.form['new_function'],
'position_qualifications' : REQUEST.form['new_qualifications'],
'position_duties' : REQUEST.form['new_duties'],
'org_name' : REQUEST.form['new_organization'],
'offer_expires' : REQUEST.form['new_expires'],
'date_posted' : REQUEST.form['new_posted'],
'notes' : REQUEST.form['new_notes']
})">

<table align=center valign=center>
<br><br><br>
<tr>
<td><h2><em>"<dtml-var jobID>"</em> added! </h2></td>
</tr>
<tr>
<td><input type=submit value=" Okay "></td>
</tr>
</table>
</form>

<dtml-var standard_html_footer>

Now I'll be emailing all of you the entire contents of my H.D.! Just
kidding. :-) Any advice would be greatly appreciated.

-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/