[Zope-Checkins] CVS: Zope3/lib/python/Zope/ObjectHub - ObjectHub.py:1.1.2.7
Jeremy Hylton
jeremy@zope.com
Wed, 20 Mar 2002 17:16:47 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/ObjectHub
In directory cvs.zope.org:/tmp/cvs-serv31641
Modified Files:
Tag: Zope-3x-branch
ObjectHub.py
Log Message:
Implement a simpler, more efficient randid(), although it's still not
clear what the random number needs to be positive half the time and
negative half the time.
=== Zope3/lib/python/Zope/ObjectHub/ObjectHub.py 1.1.2.6 => 1.1.2.7 ===
from Zope.ComponentArchitecture import getAdapter
-# Code taken from PluginIndexes/common/randid.py
-import whrandom
-def randid(randint=whrandom.randint, choice=whrandom.choice, signs=(-1,1)):
- return choice(signs)*randint(1,2000000000)
-del whrandom
+import random
+def randid():
+ # Return a random number between -2*10**9 and 2*10**9, but not 0.
+ abs = random.randrange(1, 2000000001)
+ if random.random() < 0.5:
+ return -abs
+ else:
+ return abs
-class ObjectHubError(Exception): pass
+class ObjectHubError(Exception):
+ pass
class ObjectHub(Persistent):