[Zope] Generating unique keys
Michel Pelletier
michel@digicool.com
Sun, 10 Oct 1999 18:06:45 -0400
Stuart 'Zen' Bishop wrote:
>
> I need to generate unique ID's for objects I'll be creating from DTML. This
> of course needs to be thread safe. Although I can't do this out of the box
> from within DTML (that I know of), I could get thread safety using an
> external method, or a persistant object written in Python, and using locks
> provided by the Python thread module. I think a persistant object (lets call
> it ZSequence) would be best.
>
> However, all this falls down if we want the code to run under ZEO in the
> future. And using a SEQUENCE in my Oracle database might work for me, but
> I want avoid using my RDBMS if possible.
>
> Can I use the Transaction system? I don't want to do a full commit, as this
> would have unknow effects on whatever is referencing this object. Can I
> commit changes to a dirty object, without affecting the rest of the
> transaction? (I've looked at cPersistence.c, which did nothing but remind we
> why I havn't programmed in C for years :-) )
>
> Any thoughts? Have I missed some fundamental ZODB concept that solves
> these issues?
No. No one has had the need to solve the problem yet concerning the ZEO
issue. For a single process space Zope (ie, intra-thread but
inter-process) there is a how-to on how to generate unique ides. For a
zeo envorinment, I would suggesting using Apache's unique ID module
which passes in a unique id with an environment variable for each
request, guarenteed (or at least odds in the billions to one against it
not being) unique across a set of machines which synchronize via Network
Time Protocol.
-Michel
>
> ___
> // Zen (alias Stuart Bishop) Work: zen@cs.rmit.edu.au
> // E N Senior Systems Alchemist Play: zen@shangri-la.dropbear.id.au
> //__ Computer Science, RMIT WWW: http://www.cs.rmit.edu.au/~zen
>
> _______________________________________________
> Zope maillist - Zope@zope.org
> http://www.zope.org/mailman/listinfo/zope
>
> (Related lists - please, no cross posts or HTML encoding!
>
> To receive general Zope announcements, see:
> http://www.zope.org/mailman/listinfo/zope-announce
>
> For developer-specific issues, zope-dev@zope.org -
> http://www.zope.org/mailman/listinfo/zope-dev )