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

N Burnett neil_b@yahoo.co.uk
Fri, 12 Apr 2002 17:03:28 +0100 (BST)


I have been trying for a while to get arguments passed
to a ZSQL 
Method from inside a dtml-in loop. My top level
objective is to 
update a table with multiple changes to date/times and
descriptions in records about 
conference sessions input from a form. Having read
many posts here 
and other documentation, my current attempt should
work, but I can't 
get it right yet. I keep getting a TypeError in the
DateTime function 
indicating that the date isn't being passed in the
format I think it should be:

Here is the dtml I am trying:

(The relevant fields in the table are:
ID,StartsAt,aDescription)

<dtml-var standard_html_header>
<dtml-if expr="REQUEST.has_key('submit')">
<dtml-in s>
 <dtml-call expr="sessions_modifydates(_)">
</dtml-in>
</dtml-if>

<form method=post action=sessions_update>
<table>
<dtml-in sessions_list>
<tr><td>
<input type=text name=s.ID:records value=<dtml-var ID>
size=4>
</td><td>
<input type=text name=s.StartsAt:records:date 
value="<dtml-var 
StartsAt>">
</td><td>
<input type=text name=s.aDescription:records 
value="<dtml-var 
aDescription>" size=60>
</td><tr>
</dtml-in>
</table>
<input type=submit name=submit>
</form>
<dtml-var standard_html_footer>

The (not very well named) ZSQL Method
sessions_modifydates is as follows. If it gets a date 
that DateTime can recognize, it converts it to SQL
format:

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>

(Note that commenting out the updating of the date
then allows the description to be updated, so I think
everything else works OK. I use 'aDescription' because
I thought Description may have been a reserved word
somewhere along the line, but it probably isn't.)

For completeness, here is the traceback I get:

Traceback (innermost last):
  File
C:\Programmer\WebSite\lib\python\ZPublisher\Publish.py,
line 
150, in publish_module
  File
C:\Programmer\WebSite\lib\python\ZPublisher\Publish.py,
line 
114, in publish
  File
C:\Programmer\WebSite\lib\python\Zope\__init__.py,
line 158, 
in zpublisher_exception_hook
    (Object: sss)
  File
C:\Programmer\WebSite\lib\python\ZPublisher\Publish.py,
line 
98, in publish
  File
C:\Programmer\WebSite\lib\python\ZPublisher\mapply.py,
line 
88, in mapply
    (Object: sessions_update)
  File
C:\Programmer\WebSite\lib\python\ZPublisher\Publish.py,
line 
39, in call_object
    (Object: sessions_update)
  File
C:\Programmer\WebSite\lib\python\OFS\DTMLMethod.py,
line 127, 
in __call__
    (Object: sessions_update)
  File 
C:\Programmer\WebSite\lib\python\DocumentTemplate\DT_String.py,
line 
473, in __call__
    (Object: sessions_update)
  File
C:\Programmer\WebSite\lib\python\DocumentTemplate\DT_In.py,

line 695, in renderwob
    (Object: s)
  File
C:\Programmer\WebSite\lib\python\DocumentTemplate\DT_Util.py,

line 159, in eval
    (Object:
sessions_modifydates(StartsAt=_['sequence-var-
StartsAt']))
    (Info: _)
  File <string>, line 2, in f
  File
C:\Programmer\WebSite\lib\python\Shared\DC\ZRDB\DA.py,
line 
414, in __call__
    (Object: sessions_modifydates)
  File 
C:\Programmer\WebSite\lib\python\DocumentTemplate\DT_String.py,
line 
473, in __call__
    (Object: <string>)
  File
C:\Programmer\WebSite\lib\python\DocumentTemplate\DT_Util.py,

line 159, in eval
    (Object: _.DateTime(StartsAt).strftime('#%m/%d/%Y
%H:%M:%S#'))
    (Info: StartsAt)
  File <string>, line 2, in f
  File
C:\Programmer\WebSite\lib\python\DateTime\DateTime.py,
line 
671, in __init__
  File
C:\Programmer\WebSite\lib\python\DateTime\DateTime.py,
line 
279, in _calcSD
TypeError: (see above)

Thanks in 
advance for any advice.

Regards

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