[Zope-CMF] Dates - adding my own - how?

Meilicke, Scott scott.meilicke@intp.com
Tue, 16 Oct 2001 14:05:39 -0700


Hi,

I'm trying to add a date, and have it formatted like EffectiveDate.
Example: I enter 10/18/2001, and it returns 2001-10-18 00:00:00.  I'm
assuming I need this format to do any sort of date searching later on.  

So, in the product that uses my date, called ReleaseDate, I've added by
copy/paste from dublincore.py:

    security.declarePublic( 'ReleaseDate' )
    def ReleaseDate( self ):
        """
            Dublin Core element - date resource was released.
        """
        return self.release_date and self.release_date.ISO() or 'None'

    security.declarePrivate( '_datify' )
    def _datify( self, attrib ):
        if attrib == 'None':
            attrib = None
        elif not isinstance( attrib, DateTime ):
            if attrib is not None:
                attrib = DateTime( attrib )
        return attrib
        
        security.declareProtected( CMFCorePermissions.ModifyPortalContent
                             , 'setReleaseDate' )
    def setReleaseDate( self, release_date ):
        """
            Dublin Core element - date resource was released.
        """
        self.release_date = self._datify( release_date )

However, when I call my edit form, the following gives me an error:

<dtml-let effectiveString="effective_date and effective_date.ISO() or
'None'"
          expirationString="expiration_date and expiration_date.ISO() or
'None'"
					releaseString="release_date and
release_date.ISO() or 'None'">
 
^^^^^^
Here's the traceback:

Error Type: AttributeError
Error Value: ISO

Traceback (innermost last):
  File D:\PROGRA~1\intranet\lib\python\ZPublisher\Publish.py, line 223, in
publish_module
  File D:\PROGRA~1\intranet\lib\python\ZPublisher\Publish.py, line 187, in
publish
  File D:\PROGRA~1\intranet\lib\python\Zope\__init__.py, line 226, in
zpublisher_exception_hook
    (Object: DynamicType)
  File D:\PROGRA~1\intranet\lib\python\ZPublisher\Publish.py, line 171, in
publish
  File D:\PROGRA~1\intranet\lib\python\ZPublisher\mapply.py, line 160, in
mapply
    (Object: marketitem_edit)
  File D:\PROGRA~1\intranet\lib\python\ZPublisher\Publish.py, line 112, in
call_object
    (Object: marketitem_edit)
  File D:\PROGRA~1\intranet\lib\python\Shared\DC\Scripts\Bindings.py, line
324, in __call__
    (Object: marketitem_edit)
  File D:\PROGRA~1\intranet\lib\python\Shared\DC\Scripts\Bindings.py, line
354, in _bindAndExec
    (Object: marketitem_edit)
  File D:\PROGRA~1\intranet\lib\python\Products\CMFCore\FSPythonScript.py,
line 187, in _exec
    (Object: marketitem_edit)
    (Info: ({'script': <FSPythonScript instance at 019BBBA8>, 'context':
<MarketItem instance at 016C10E0>, 'container': <CMFSite instance at
01A4BF08>, 'traverse_subpath': []}, (ZServerHTTPResponse(''), '', '', '',
[''], 'html', '10/19/2001', '2001-10-18 00:00:00', 'None', ['']), {}, (None,
None, None)))
  File Script (Python), line 61, in marketitem_edit
  File D:\PROGRA~1\intranet\lib\python\Products\CMFCore\FSDTMLMethod.py,
line 180, in __call__
    (Object: marketitem_edit_form)
  File D:\PROGRA~1\intranet\lib\python\DocumentTemplate\DT_String.py, line
544, in __call__
    (Object: marketitem_edit_form)
  File D:\PROGRA~1\intranet\lib\python\DocumentTemplate\DT_Let.py, line 147,
in render
    (Object: effectiveString="effective_date and effective_date.ISO() or
'None'"
          expirationString="expiration_date and expiration_date.ISO() or
'None'"
					releaseString="release_date and
release_date.ISO() or 'None'")
  File D:\PROGRA~1\intranet\lib\python\DocumentTemplate\DT_Util.py, line
230, in eval
    (Object: release_date and release_date.ISO() or 'None')
    (Info: release_date)
  File <string>, line 0, in ?
AttributeError: (see above)

TIA - Scott