[Zope-dev] Adding a Date Property to a Z-Class

Tim McLaughlin tim@iterationzero.com
Thu, 23 Aug 2001 13:07:31 -0400


Matt,
Not really the right list for this discussion... zope would be a better
one.  Nonetheless, I suspect your problem is the marshaling of the
value.  Try naming the field like this
<input type=hidden name="now:date" value="...">

note, the :date part in the name is the important bit because it'll
convert the string into a date.

Tim

> 
> Hi there,
> 
> I'm a bit out of my depth here but I have a problem and I'm hoping someone
> can help...
> 
> I created a simple product containing a Z-Class with various properties
> (along the lines of the Beehive tutorial).  I then created both management
> interface and web based forms for creating instances of this Z-Class.
> It works great...but I would now like to add a date property to the Z-Class
> - so that I can conduct searches of all the Z-Class instances by date.  In
> order to add the date property to the Z-Class I had to include a default
> value in the property sheet - no problem there.  However when I come to add
> an instance through my web based forms I get the following error:
> 
> Error type: Invalid Date-Time String
> Error value:
> The date value from my form is passed as a hidden field with the following:
> > 
> Hi there,
> 
> I'm a bit out of my depth here but I have a problem and I'm hoping someone
> can help...
> 
> I created a simple product containing a Z-Class with various properties
> (along the lines of the Beehive tutorial).  I then created both management
> interface and web based forms for creating instances of this Z-Class.
> It works great...but I would now like to add a date property to the Z-Class
> - so that I can conduct searches of all the Z-Class instances by date.  In
> order to add the date property to the Z-Class I had to include a default
> value in the property sheet - no problem there.  However when I come to add
> an instance through my web based forms I get the following error:
> 
> Error type: Invalid Date-Time String
> Error value:
> The date value from my form is passed as a hidden field with the following:
> value = "<dtml-var expr="_.DateTime().Date()">" which I believe to be a
> valid format.
> I have a feeling what is happening is that the date value is simply not
> reaching the object manager when I create the Z-Class instance - it is
> created as follows:
> <dtml-call "REQUEST.set('PostingNo.',REQUEST.form['new_PostingNo.'])">
>   <dtml-with "manage_addProduct['portal_posting']">
>     <dtml-call "posting_class_add(_.None,_, NoRedir=1)">
>   </dtml-with>
> 
>   <dtml-in "objectValues(['posting'])">
>    <dtml-if "(_['sequence-item'].id == REQUEST.form['new_PostingNo.'])">
>     <dtml-call "REQUEST.set('our_posting',_['sequence-item'])">
>    </dtml-if>
>   </dtml-in>
> 
>   <dtml-call
> "_['our_posting'].propertysheets.posting_description.manage_changeProperties
> ({
>      'Author'              :REQUEST.form['new_Author'],
>      'Title'                 :REQUEST.form['new_Title'],
>      'Topic'               :REQUEST.form['new_Topic'],
>      'Lead'                :REQUEST.form['new_Lead'],
>      'Body'               :REQUEST.form['new_Body'],
>      'Date'                :REQUEST.form['new_Date']
>   })">
> 
> It's probably worth pointing out that I can add instances (complete with a
> date property) through the management interface forms. Any ideas on how I
> could get the Date value to be passed through web based forms would be
> greatly appreciated!!
> 
> Thanks,
> 
> Matt
> --
> Matthew Anderson - Web Designer - Frontier Internet Services Limited
> Tel: 029 20 820 019   Fax: 029 20 820 037   http://www.frontier.net.uk
> Statements made are at all times subject to Frontier's Terms and Conditions
> of Business, which are available upon request.
> " which I believe to be a
> valid format.
> I have a feeling what is happening is that the date value is simply not
> reaching the object manager when I create the Z-Class instance - it is
> created as follows:
> <dtml-call "REQUEST.set('PostingNo.',REQUEST.form['new_PostingNo.'])">
>   <dtml-with "manage_addProduct['portal_posting']">
>     <dtml-call "posting_class_add(_.None,_, NoRedir=1)">
>   </dtml-with>
> 
>   <dtml-in "objectValues(['posting'])">
>    <dtml-if "(_['sequence-item'].id == REQUEST.form['new_PostingNo.'])">
>     <dtml-call "REQUEST.set('our_posting',_['sequence-item'])">
>    </dtml-if>
>   </dtml-in>
> 
>   <dtml-call
> "_['our_posting'].propertysheets.posting_description.manage_changeProperties
> ({
>      'Author'              :REQUEST.form['new_Author'],
>      'Title'                 :REQUEST.form['new_Title'],
>      'Topic'               :REQUEST.form['new_Topic'],
>      'Lead'                :REQUEST.form['new_Lead'],
>      'Body'               :REQUEST.form['new_Body'],
>      'Date'                :REQUEST.form['new_Date']
>   })">
> 
> It's probably worth pointing out that I can add instances (complete with a
> date property) through the management interface forms. Any ideas on how I
> could get the Date value to be passed through web based forms would be
> greatly appreciated!!
> 
> Thanks,
> 
> Matt
> --
> Matthew Anderson - Web Designer - Frontier Internet Services Limited
> Tel: 029 20 820 019   Fax: 029 20 820 037   http://www.frontier.net.uk
> Statements made are at all times subject to Frontier's Terms and Conditions
> of Business, which are available upon request.
> 
-- 
Tim McLaughlin
iterationZERO - www.iterationzero.com
703.481.2233