[Tutor] Persistent store for a single integer

Patrick Phalen python-tutor@teleo.net
Thu, 3 Feb 2000 17:47:28 -0800


I'm writing a CGI script which appends information gathered from a form
to a file, which in turn is to be FTP'd to the client once a day for
followup.

The specification requires that a Unique ID number be incremented and
assigned to every person filling out a form, and that ID then is
attached to each of the dozen or so individual fields at file writing
time.

The Unique ID is an integer starting at 1000000 and incrementing by 1
for each new "customer."

So, in other words, when I write the data to the file, I need to
determine the last-used integer, increment it and concatenate this
UniqueID to most of the fields.

What is a good persistence model for this integer? A file with a
mutex/lock? A pickled numeral? These seem kind of expensive.

Naturally, I want to avoid data corruption in the case where many people
might access the form at once, take arbitrary time to complete the
form, etc., without blocking people for lengthy periods.