[Zope] Postponing insertion in database

Christian Theune ct@gocept.com
Mon, 11 Feb 2002 11:26:52 +0100


Hi Juan.

On Mon, Feb 11, 2002 at 10:43:03AM +0100, Juan Garcia Garcia wrote:
> Hi,
>=20
>   my problem is that i have three consecutive forms: when i click the
> submit button of the first one, i insert in the database and then
> redirect to the second form, and the same with the second and third.
> But the three insertions must be completed if i want to have a database
> not corrupted. If the user stops in the second form, for example by
> closing the navigator, the previous insertion must be undone.
>=20
> I thought two solutions, the first one is using hidden inputs and inser=
t
> all in the last step, but i don=B4t like very much this solution. The
> other one is using transactions, but i don't know how to manage them.

Well, the first solution is ok most time, as you think of "remember evert=
hing
until the last step, then make all at once". Some approaches you could do=
 this
easier (and probably safer) may include using sessioning (storing the dat=
a
already submitted in a session object) or encoding your collected data in=
to
one string and only using one hidden field to aggregate data. then insert=
 everthing
at once is fine.

The other approach to use transactions won't work because in zope you wil=
l only
be able (currently, and i think for a long time also) to have the (intern=
al as well
as external) transactions in one request. You *could* try using cursors i=
f you want to
handle the data aggregation within the database, but that's a really comp=
licated thing
when not beeing able to have it in a native transaction environment. try =
the first
approach will be easier. :)


>=20
> Anyone could help me with a suggestion or a link?
>=20
> Zope 2.4.2
> ZPsycopgDA 1.0
> PostgreSQL 7.1.3

PG: good choice

>=20
> Thanks.
> Bye. Juan
>=20

np. Christian.

--=20
Christian Theune - ct@gocept.com
gocept gmbh & co.kg - schalaunische strasse 6 - 06366 koethen/anhalt
tel.+49 3496 3099112 - fax.+49 3496 3099118 mob. - 0178 48 33 981

reduce(lambda x,y:x+y,[chr(ord(x)^42) for x in 'zS^BED\nX_FOY\x0b'])