[Zope] Q. on Persistence.Persistent

Alex Rice alrice@swcp.com
Sun, 1 Aug 1999 14:18:21 -0600 (MDT)


Suppose I have a zclass which inherits like this

my_ZClass( my_python_class( Persistence.Persistent,Acquisition.Implicit))

In my_python_class, I have something like the following segment:

  def doStuffToCount(self, newcount):
     _count=self._count     # get persistent count
     _count=_count+newcount # increase count
     ...                    # maybe do other stuff
     self._count=_count     # save persistent count again
     return _count

My reading of Michel P. and Jim F.'s posts in recent threads about
Persistence and ZODB3, is that this this method above is basically an
atomic opertation as far as ODB3 is concerned, and I do not have to
worry that another thread is going to touch self._count in between
_count=self._count and self._count=_count. Is this correct?

If I am misunderstanding, is there the equivalent to java's synchronized
keyword that one would use in this scenario?

Thanks,

-- 
Alex Rice    |    alrice@swcp.com    |    http://www.swcp.com/~alrice
    Current Location: N. Rio Grande Bioregion, Southwestern USA