[Zope] Zope with Microsoft Access

Rik Hoekstra rik.hoekstra@inghist.nl
Fri, 24 Nov 2000 18:21:47 +0100


> Hi, this is my first posting to the list, and about my 4th day working
with
> Zope.  I have a bit of a problem.  All my code so far is working well.
Just
> the following section is defying my attempts to make it run.  What it does
> is to update a field in the database (to allow employees to quickly update
> their hours in the hours tracking thing I'm creating)  it's complex since
> all the employees hours will be listed on one page and will be instantly
> updatable (with a select box that allows the choice of +/- (name is
> modify<dtml-var hoursID> and value is either + <hours already input> or -
> <hours already input>) and a text field for entering hours to add or
> subtract (name is mod_hours<dtml-var hoursID>)).
>
> The code (in the DTML document) is:
>
> <dtml-in "REQUEST.form.items()">
> <dtml-if "_.string.find(_['sequence-key'], 'mod_hours')">
> <dtml-else>
> <dtml-let mykey=sequence-key myval=sequence-item>
> <dtml-in "REQUEST.form.items()">
> <dtml-if "_.string.find(_['sequence-key'], 'modify')">
> <dtml-else>
> <dtml-if "_['sequence-key'][6:9] == mykey[9:12]">
> <dtml-if myval>
> <dtml-call UpdateHours(REQUEST)>
> </dtml-if>
> </dtml-if>
>
> </dtml-if>
> </dtml-in>
>
> </dtml-let>
> </dtml-if>
> </dtml-in>
>
> and the SQL method UpdateHours is:
>
> update emp_hours set hours =
> <dtml-var expr="_['sequence-item']">
> <dtml-var expr="_['myval']">
> where
> hoursID = <dtml-var expr="_['mykey'][9:12]">;
>
> with arguments: sequence-item, myval, mykey
>
> I've tried everything I can think of but it not only refuses to do
anything,
> it also refuses to raise an error.
>
> If anyone can help out I'd be very grateful.
>

This seems to be more of a DTML problem than an Access problem. It is hard
to follow anyway...
A few questions: have you tried using something like changing the form names
to using the name.item:records syntax. something like

<input type="checkbox" name="modify.<dtml-var hoursID>:records" value="+">
<input type="checkbox" name="modify.<dtml-var hoursID>:records" value="-">
<input type="hidden" name="modify.inputhrs:records" value="<hours already
input>">
and a text field for entering hours to add or
<input type= "text"  name="modify.mod_hours:records" value="<dtml-var
hoursID>">

this will give your dtml method a dictionary like structure called modify
you can loop over.

Starting from there will save you a whole lot of hacking. Also I'm not at
all sure that you can use the [sequenct-key] as arguments for your SQL
Method.

On the records and types in forms see:
http://www.zope.org/Members/Zen/howto/FormVariableTypes

hth

Rik