[zopeorg-checkins] CVS: Products/ZopeOrg-NV - SoftwareProduct.py:1.26

Kapil Thangavelu kvthan at wm.edu
Fri Jun 7 15:42:29 EDT 2002


Update of /cvs-zopeorg/Products/ZopeOrg-NV
In directory cvs.zope.org:/tmp/cvs-serv27858

Modified Files:
	SoftwareProduct.py 
Log Message:
Changes to Tiny Counter to inherit from BTrees.Length, this will yield a minor
storage savings, as Lengths serialize to only a python integer. more importantly
Lengths define application conflict resolution for better concurrency.



=== Products/ZopeOrg-NV/SoftwareProduct.py 1.25 => 1.26 ===
 from AccessControl import ClassSecurityInfo
 from AccessControl.SecurityManagement import getSecurityManager
+from BTrees.Length import Length
 from OFS.Image import File
 from OFS.SimpleItem import SimpleItem
 from OFS.content_types import guess_content_type
@@ -482,24 +483,20 @@
 Globals.InitializeClass(SoftwareReleaseFile)
 
 
-class TinyCounter( Persistent ):
+class TinyCounter( Length ):
     """ Class to hold a counter """
     security = ClassSecurityInfo()
 
-    def __init__( self ):
-        self.counter = 0
-
     security.declarePublic( '__add__' )
     def __add__( self, other ):
         """ Add to me """
-        self.counter = self.counter + int( other )
-
-        return self.counter
+        self.value += int(other)
+        return self.value
 
     security.declarePublic( '__repr__' )
     def __repr__( self ):
         """ Show me """
-        return str( self.counter )
+        return str( self.value )
 
 Globals.InitializeClass( TinyCounter )
 






More information about the zopeorg-checkins mailing list