[Zope] Re: Initialising DateTime object from SQL query

John Wheeler jdw27_42@hotmail.com
Sun, 10 Feb 2002 04:54:51


Okay, I scanned ahead and didn't see a reply to this problem, so I'll take a 
stab at it.

My first guess was that the problem with the following line:

<dtml-var 
expr="selectDate_dtml(_.None,_,id='s',default=_.DateTime('2002/02/08'))">

was that with the default= syntax, the function is being passed as an 
address, rather than being called. However, that doesn't explain why it does 
work without a parameter.

What I would suggest, if the default parameter is _always_ the result of a 
DateTime call, move the DateTime call into the python script and pass the 
default parameter to it.

Hope that helps.
John Wheeler


>Date: Fri, 8 Feb 2002 12:10:28 +0000
>From: Paul Roberts <paul.m.roberts@sun.com>
>To: zope@zope.org
>Subject: [Zope] Initialising DateTime object from SQL query
>
>Hello everyone,
>
>Sorry in advance for the elongated description of my problem, I
>just want to make sure I include all the information that might be
>required...
>
>I have a dtml-method which will automaticly create date selection
>elements for a form. I pass it a default date in the form of a DateTime
>object. The value of the form elements is then initialised to this date.
>
>Normally I just run it like this:
>
><dtml-var expr="selectDate_dtml(_.None,_,id='s',default=_.DateTime())">
>
>Which sets the default date to the current one, and this works fine.
>
>However, sometimes I want to initialise this bit of the form with a date
>extracted from an SQL query. I can access the field in question without
>a problem as a normal variable:
>
><dtml-var date_start>
>
>displays as 2002/02/08
>
>Now, I know that this format is appropriate to pass to the constructer
>for DateTime, because when I type in a date by hand, it works fine:
>
><dtml-var 
>expr="selectDate_dtml(_.None,_,id='s',default=_.DateTime('2002/02/08'))">
>
>However, when I pass the date_start variable to my dtml method as
>_.DateTime(date_start), I get the following error message:
>
>---
>
>Zope Error
>
>Zope has encountered an error while publishing this resource.
>
>Error Type: TypeError
>Error Value: unsupported operand type(s) for /
>
>---
>
>It looks like it isn't passing this variable to DateTime as a string, so
>how do I make it do that?
>
>Thanks in advance for any help you can offer. - Paul
>
>--
>Paul Roberts <paul.m.roberts@sun.com>





_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com