[Zope3-Users] Re: RFC 4122 UUIDs
Benji York
benji at zope.com
Wed Apr 4 14:48:06 EDT 2007
Derek Richardson wrote:
> I believe that that will not guarantee a *universally* unique id, but
> only an id unique within that ZODB. Am I wrong?
>
> The RFC prescribes a specific algorithm for generating universally
> unique IDs.
Of course, they are only "universally unique" in a probabilistic way.
It wouldn't be difficult to salt the integer IDs such that they generate
UUIDs that are as likely as any other to be unique. Something like this
would work:
import uuid
int_id = 42
salt = 0x32352352353243263235235235324326
print uuid.UUID('%X' % (int_id ^ salt))
Another option would be to create an IOBtree to map each object's intid
to a randomly generated UUID (generated by the uuid.uuid1 method from
the earlier referenced module).
--
Benji York
Senior Software Engineer
Zope Corporation
More information about the Zope3-users
mailing list