How do you lock your web app data?

Gilles Lenfant glenfant at equod.com.nospam
Tue Jan 30 13:53:15 EST 2001


If you play with lot of small files and few users you can use "lock files"
with the same name as the file the user is supposed to modify.
This is not "pythonic" but a general algorythm that can be done in python or
whatever:

start cgi
if not exists "myfile.lock"
  touch "myfile.lock"
  # play with "myfile.txt"
  ...
  # end play with "myfile.txt"
  rm "myfile.lock"
else
  reply "resource in use, come back later" to the user (or anything else
relevant)
endif
end cgi

Of course, this will not be appropriate to big traffic and if the cgi script
crashes (beetween "# play..." and "# end play...") and leaves
"myfile.lock"... nobody will be capable of using your application.

In some months, your application complexity will perhaps grow such that
staying with cgi technology will lead to headaches for you and your server.

There are better "pythonic" solutions than cgi for playing with shared
complex objects and lots of users in a "safer" way. see Zope at www.zope.org
that offers an open source Python based applications server that's better
suited to complex Web based applications.

"Franz GEIGER" <fgeiger at datec.at> a écrit dans le message news:
956uqd$6st$1 at newsreaderg1.core.theplanet.net...
>
> Hi all,
>
> I began to play around with cgi scripts and of course use Python for that.
> And man, it is a pleasure to do that with Python! It really is a snap.
After
> about a day I had written an Issue Tracker, where People can add software
> feature requests and bug reports. At this time I add functionality to edit
> and delete the entries - until now they only could have been added.
>
> 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
> nor will it be to handle requests and reports from hundreds of people.
> Therefore and because I just settled out to explore cgi I decided to use
> text files and pickle files for maintaining data and state, which is very
> convenient.
>
> 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?
>
> The server is an NT box running IIS4. Python is of version 2.0
(AvtiveState
> distribution).
>
> Any hint is appreciated.
>
> Thanks in advance and best regards
> Franz GEIGER
>
>
>
>




More information about the Python-list mailing list