[Zope] Datefields
Tim Hawes
User.Name@ncmail.net
Tue, 12 Mar 2002 09:10:56 -0500
Joel Burton wrote:
> On Mon, 11 Mar 2002, Tim Hawes wrote:
>
> > ZPsycoPG returns datefields from postgress in yyyy/mm/dd format, while
> > postgres' default is yyyy-mm-dd. I need to pass a date to python script
> > for comparison w/ other datefields, but Zope apparently will not allow
> > values to be passed with '/'s in them. Can I change the way ZPsycoPG is
> > returning the date fields in the database? How?
>
> Zope has no problem with passing a string like "2001/01/01" to a Python
> Script. Why do you think that Zope will apparently not allow values to be
> passed with "/" in them?
>
>
Zope Error
Zope has encountered an error while publishing this
resource.
Error Type: TypeError
Error Value: unsupported operand type(s) for /
Traceback (innermost last):
File /usr/local/zope/2.5.0/lib/python/ZPublisher/Publish.py, line 150, in
publish_module
File /usr/local/zope/2.5.0/lib/python/ZPublisher/Publish.py, line 114, in
publish
File /usr/local/zope/2.5.0/lib/python/Zope/__init__.py, line 158, in
zpublisher_exception_hook
(Object: Projects)
File /usr/local/zope/2.5.0/lib/python/ZPublisher/Publish.py, line 98, in
publish
File /usr/local/zope/2.5.0/lib/python/ZPublisher/mapply.py, line 88, in
mapply
(Object: ChangeProject)
File /usr/local/zope/2.5.0/lib/python/ZPublisher/Publish.py, line 39, in
call_object
(Object: ChangeProject)
File /usr/local/zope/2.5.0/lib/python/OFS/DTMLMethod.py, line 127, in
__call__
(Object: ChangeProject)
File /usr/local/zope/2.5.0/lib/python/DocumentTemplate/DT_String.py, line
473, in __call__
(Object: ChangeProject)
File /usr/local/zope/2.5.0/lib/python/DocumentTemplate/DT_In.py, line 695,
in renderwob
(Object: ProjectsUpdateResultMethod)
File /usr/local/zope/2.5.0/lib/python/DocumentTemplate/DT_Util.py, line 159,
in eval
(Object: compare_datefield('start_',proj_start))
(Info: compare_datefield)
File <string>, line 2, in f
File /usr/local/zope/2.5.0/lib/python/Shared/DC/Scripts/Bindings.py, line
252, in __call__
(Object: compare_datefield)
File /usr/local/zope/2.5.0/lib/python/Shared/DC/Scripts/Bindings.py, line
283, in _bindAndExec
(Object: compare_datefield)
File
/usr/local/zope/2.5.0/lib/python/Products/PythonScripts/PythonScript.py, line
291, in _exec
(Object: compare_datefield)
(Info: ({'script': <PythonScript instance at 1235610>, 'context': <r
instance at 1383f28>, 'container': <Application instance at dd8220>,
'traverse_subpath': []}, ('start_', DateTime('2002/02/25')), {}, None))
File Script (Python), line 50, in compare_datefield
File Script (Python), line 12, in cdate
File /usr/local/zope/2.5.0/lib/python/DateTime/DateTime.py, line 668, in
__init__
File /usr/local/zope/2.5.0/lib/python/DateTime/DateTime.py, line 276, in
_calcSD
TypeError: (see above)
When I try to put this value in when I test the python script 'compare_date',
it has no problems. I pass the value in dtml, I get this error. This is what
has led me to believe that the problem is in how Zope handles it.
Now, looking at it, perhaps the problem is in how I am calling it in dtml?
Here is the dtml code that I use inside a database query sequence:
<dtml-var expr="compare_datefield('start_',proj_start)">
The first parameter is for an input tag variable name that is prepended to the
default, the second (proj_start) is a dtml var containing a datefield for the
script to compare. The end result is html code containing individual selection
boxes for day, month and year, w/ the default selection at what is already in
the database. I have another version of this script working that compares the
DateTime() value with all date
ranges to produce defaults for the current day, month, and year, and
compare_date() does the same thing
except that it creates a new DateTime() object from the second parameter that
is passed to it.