Re: [Zope] Unique IDs
Or is there a better way of doing it?
One additional: using a hash algorithm does produce unique values in many cases but doesn't guarantee them. If uniqueness is an absolute requirement you have to check if a key already exists and generate another one in this case (using a different secret f.e.).
Hm, out of interest, is there a way to be sure to get atomicity for the above algorithm? Otherwise there is always a small timespan in which an object with the same name could have been created - after the above check, but before you create it. Wouldn't it be simpler (in typical zope cases) to just try to create the objects in the same folder and just wrap the id generation and object creation in a try/except clause? And additionally - instead of using hashes - just to use a timestamp? cheers, oliver
And additionally - instead of using hashes - just to use a timestamp?
The key thing I need is unpredictability - hence my originally wanting to use md5 as the last step in the generation. The 'usual' way to do this is to seed the random number generator with the current time, pull a number out of that and then do an md5 on it. I've got a number of options now, I'll look at them However, this doesn't answer the first part of my original question - why is Zope asking me for further credentials when I try to use the md5 module? I'm guessing md5 is in the security sin bin along with re and other stuff... but why md5? Curious... Cheers, Dan _________________________________________________________________ Daniel Fairs | daniel.fairs@spiderplant.net | www.spiderplant.net
participants (2)
-
Daniel Fairs -
Oliver Bleutgen