[Zope] Lock and Transaction in Zope.

Dieter Maurer dieter@handshake.de
Thu, 7 Sep 2000 22:13:42 +0200 (CEST)


Aitor Grajal writes:
 > --=====_9682482706334=_
 > Content-Type: text/plain; charset="ISO-8859-1"
 > Content-Transfer-Encoding: quoted-printable
I hate "multipart" or encoded messages to this list (because the digest
removes MIME headers (what a stupidity!) and does not give my
mail reader a chance to decode them).

 >  ... two requests concurrently accessing the same object ...
 >  The first one crashes, and doesn't finish right....
 >  I want to know if there is any way to lock ...
 >  about locking resources in Zope.
You do strange things...

Zope tries hard to avoid locking and uses an optimistic
collision policy instead. Several threads can
run concurrently on separate copies of an object.
If, during commit, a collision is detected, the
affected transaction is aborted and (I think I read that)
restarted.

If you really need locking, you can use Pythons "threading"
module (in a package used from an external method).
You must be careful, though.
Look in the archive for a message from Sean McGrath
about the potential problem involved and my reply
for a solution.

You may also look (as an example) at
	URL:http://www.dieter.handshake.de/pyprojects/zope/SharedResource.html
It uses looks to protect resources shared by several threads.


Dieter