[Zope-dev] Globally unique id's in Zope in a new way

Damian Morton morton@dennisinter.com
Thu, 9 Mar 2000 14:50:23 -0500


I thought the GUID was a 128bit number. Its not _guaranteed_ to be unique,
it just has a very very high probability of being unique.

You can create a globally unique number by combining the 64 bit OID for the
object with a 64 bit random number (possibly from the network card address
or somesuch) that is generated once for each zope installation.

The 64bit OID is available as object._p_oid, and should be unique within a
ZODB for the lifespan of that ZODB.

Theres also a 64bit serial number (which i believe is a timestamp) available
as object._p_serial

Reading from these values is probably fine, but writing to them might not be
a good idea.

> -----Original Message-----
> From: zope-dev-admin@zope.org [mailto:zope-dev-admin@zope.org]On Behalf
> Of Tres Seaver
> Sent: Thursday, March 09, 2000 12:34 PM
> To: James W. Howe
> Cc: zope-dev@zope.org; Jason Spisak
> Subject: Re: [Zope-dev] Globally unique id's in Zope in a new way
>
>
> "James W. Howe" <jwh@allencreek.com> wrote:
> >
> > At 07:49 PM 3/8/00 -0500, Jason Spisak wrote:
> > >Zopsters,
> > >
> > >I use the Catalog for quite a bit of jumping around the ZODB,
> and have a
> > >30,000 plus objects in a system.  I like the idea of not
> having to worry
> > >about id's conflicting with other numbers that might appear (invoice
> > >numbers, employee numbers, etc...) so I don't like to use a counter for
> > >ids.  [...]
> >
> > I have the same problem.  I want to automatically create objects and I'm
> > currently using the time method.  When I bulk add objects, I would get a
> > collision on the time value, so I simply remembered the last id
> and added 1
> > to that value.  It works for my current needs, but I wish Zope
> provided a
> > standard mechanism for generating unique id's.
> >
> > 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.
> >
> > Just an idea.
>
> On Win32, this is trivial in Python::
>
>   import pywintypes
>   guid = pywintypes.CreateGuid()
>   return str( guid )
>
> I *think* DCE RPC has a cognate function, uuid_create(), but I don't have
> documentation for it (Sun RPC probably has a similar call). Hmmm,
> a search of
> the Vaults of Parnassus (http://www.vex.net/parnassus) doesn't
> show any existing
> wrapper for either major flavor of RPC.
>
> Tres.
> --
> =========================================================
> Tres Seaver         tseaver@palladion.com    713-523-6582
> Palladion Software  http://www.palladion.com
>
> _______________________________________________
> Zope-Dev maillist  -  Zope-Dev@zope.org
> http://lists.zope.org/mailman/listinfo/zope-dev
> **  No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope )
>