[Zope-dev] Globally unique id's in Zope in a new way
Sam Gendler
sgendler@impossible.com
Thu, 09 Mar 2000 12:34:29 -0800
> For example, it would actually be nice if Zope provided an implementation
> of UUID (called GUID by Microsoft). A UUID is a guaranteed unique 64-bit
> value. It's used in COM, CORBA and other systems which need to have
> automatically generated guaranteed unique values. The nice thing about
> UUID's is that they are guaranteed to be unique network wide. In other
> words, you (supposedly) can't generate a UUID which would ever conflict
> with a UUID that I generated. It does this by an algorithm which takes
> into account things like time-of-date, network card address, etc. I don't
> have the details on the algorithm but I know it is publically
> available. It would probably best be implemented at the C level.
I just generated something like this for a product, in python. In order
to guarantee uniqueness across a cluster of servers, I use the last
octet of the ip address (assuming the cluster is all on the same
subnet), the time, a call to randint(1,10000). If you really want to
make things interesting, run that through the sha algorithm, and you get
a nice 160 bit key rendered in hex.
In obfuscated code, it looks like:
sha(split(gethostbyname(gethostname()),'.')[3]+str(int(time.time()-900000000))+str(randint(1,1000))).hexdigest()
but you would do well to make it multiple lines of code... ;-)
--sam
--
--------------------------
Sam Gendler
CTO, Impossible, Inc.
1222 State St. Suite 250
Santa Barbara, CA. 93101
p: 805-560-0508
f: 805-560-0608
c: 805-689-1191
e: sgendler@impossible.com