[Zope] dtml-in, ZSQL Method, date argument problem

N Burnett neil_b@yahoo.co.uk
Fri, 12 Apr 2002 21:12:48 +0100 (BST)


Hans

Thanks for taking the time to look at this huge
posting:-) In fact its too long for my.yahoo and it
gets truncated when I reply, so I'll cut to the
culprit:


 --- hans <hans@beehive.de> wrote: >
this is the culprit: Your DateTime argument StartsAt
is malformed in some way. Looking into
lib\python\DateTime\DateTime.py,
shows, that if the argument do DateTime() is of type
string, DateTime tries to convert string using a
method "_calcSD",
its def beeing at line 272 like

def _calcSD(t):
    # Returns timezone-independent days since epoch
and the fractional
    # part of the days.
    dd = t + EPOCH - 86400.0
    d = dd / 86400.0
    s = d - math.floor(d)
    return s, d

________________
Hans - This is indeed the culprit, but why is my date
field in the records object malformed when accessed in
this way? If I do this:

<dtml-in s>
 <dtml-var StartsAt><br>
 <dtml-call expr="sessions_modifydates(_)">
</dtml-in>

The output for the StartsAt var is fine: 2002/06/03
10:00:00 GMT+2 - which is a valid DateTime string.

In fact, if I run the ZSQL Method test directly with
this value copied and pasted from the html source of
the html form field name="s.StartsAt:records:date",
then the field gets updated properly giving this sql
statement - with some other values I entered to get a
single record in the table:

UPDATE tblSession SET
tblSession.StartsAt = #06/03/2002 10:00:00#,
tblSession.Description = 'anything'
where
(ID = 50
 and ConferenceID = 4
)

Here's the ZSQL Method again to save searching in my
previous post:

UPDATE tblSession SET
tblSession.StartsAt = <dtml-var
expr="_.DateTime(StartsAt).strftime('#%m/%d/%Y
%H:%M:%S#')">,
tblSession.Description = <dtml-sqlvar aDescription
type=string>
<dtml-sqlgroup where>
<dtml-sqltest ID op=eq type=int>
<dtml-and>
<dtml-sqltest ConferenceID op=eq type=int>
</dtml-sqlgroup>

So, it looks like my StartsAt Date/Time value is fine
if output in the dtml-in loop, but gets corrupted if
it is passed to a ZSQLMethod called inside the loop.

Thanks for your other points  by the way. I am too
lazy on double quotes in HTML, but I don't believe it
makes a difference in this case. I have added the
quotes throughout just to be sure.

Neil


__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com