How do you lock your web app data?

Alex Martelli aleaxit at yahoo.com
Wed Jan 31 03:43:49 EST 2001


"Franz GEIGER" <fgeiger at datec.at> wrote in message
news:956uqd$6st$1 at newsreaderg1.core.theplanet.net...
    [snip]
> So  an important issue enters the game: How do I lock others out, when one
> edits/writes records? Please get me right: This will not be a heavy load
app
    [snip]
> Of course I could take a database as backend but I wonder if there are
other
> possibilities to achieve that "serialization"? How do you do it? Do you
> always use a database? Is it worth the effort doing it without a database?

And the answers are: yes, with a relational DBMS, yes, no.

> The server is an NT box running IIS4. Python is of version 2.0
(AvtiveState

Others will no doubt disagree, but: when I need 'serialization' of
"edits" by different users I also need atomic transactions and reliable
recovery from errors.  A halfway-decent RDBMS gives me all of that
for free, AND very handy primitives for all kinds of data access.

For a non-heavy-load application under NT, I would use MSDE -- a freely
redistributable version of the [small version of] Microsoft SQL Server
engine, optimized for up to 5 simultaneous accesses; you can freely
download it from the Microsoft site (you are legally licensed to
redistribute it without limits IF you have a license for Microsoft
Visual Studio products, or else its Office professional version --
but IANAL, so, *do* check the details on Microsoft's site!) -- in
fact you can download and use (but NOT redistribute) the Developer
Edition of SQL Server, which in addition to that same engine has all
the usual GUI tools for DB administration, tuning, etc -- but MSDE
comes with a small packet of non-GUI tools which an old dinosaur like
me finds perfectly OK (osql.exe to pump SQL commands into any ODBC
compliant engine via commandline and/or textfiles, for example).

But there are other and freer RDBMS which one might prefer, if for
any reason one wants to eschew MSDE -- Postgres which has been
opensource forever, Interbase which has been opensourced a few
months ago, the newest version/descendant of Adabas (I forget its
current name) which is also going opensource, etc.  Just make sure
you get decent support for atomic transactions (ideally also for
integrity checks, triggers and stored procedures ... but that's just
my GREEDY side speaking!!!-).  My experience is with MSDE, but I'm
sure the others are good, too.

Hey, I bet even GADFLY would do, if you ran it in a central process
and had your scripts talk to that process with Gadfly's TCP/IP
client/server protocol (but I have no experience of *that*) --
but I don't think you'd get atomic transactions then, and I think
they ARE important.

Serialization is not normally enough -- you want some reading
operation[s] to be 'packaged up' with the writing operation[s]
that depend on it, too; this is "a transaction".  Trying to
express this need as a very elementary example...:

Just imagine that all your scripts need do is increment a
total by some amount:
    total = <read the previous total>
    total = total + new_amount
    <write the new total>

If the writes are serialized, but the read and the write are
not "packaged" as a "transaction" unit for serialization, then
sooner or later this will "miss a beat" -- two processes will
both read the same "previous total", then each will add a
different amount to it, and re-write the "new total"... the
SECOND of these writes will obliterate the first.  Not good.


Alex






More information about the Python-list mailing list