[Zope] External method called twice?
Dieter Maurer
dieter@handshake.de
Thu, 24 Apr 2003 21:55:52 +0200
Francesco Chicchiricc=F2 wrote at 2003-4-24 10:11 +0200:
> I'm in trouble with zope and external methods.
>=20
> Sometimes (and I haven't been able to detect exactly when), my externa=
l
> method get called twice, even thought it is called only once from ZPT.
Sure, your ZPT is not called twice?
External Methods are usually not called twice...
Exception:
when the call returns with a "TypeError", the first
parameter is "self" and you pass exactly one parameter less
than the necessary number of arguments, the method is called
again with the context as "self" argument.
However, in this case, the first call must have raised
TypeError immediately, before any code of the method
has been executed.
> It
> seems there are two independent threads accessing the same method's bo=
dy.
That's well possible but not a problem (unless you want to communicate
via module scope variables).
> Any suggestion? Something like Java's 'synchronize'?
It usually is not necessary.
Read "zodb3.pdf". It explains Zopes transaction support.
There is no "synchronize" but you can use looks when you
really need it.
After you have read the "zodb3" documentation, you
will understand that locks behave differently for persistent
objects. Be careful.
Dieter