[Zope-dev] Globally unique id's in Zope in a new way
Pavlos Christoforou
pavlos@gaaros.com
Wed, 8 Mar 2000 23:43:34 -0500 (EST)
On Wed, 8 Mar 2000, Jason Spisak wrote:
>
> import md5, base64, time, string
> from urllib import quote
> from whrandom import choice
> def unique_id(self):
> id=md5.new()
> id.update(self.absolute_url())
> id.update(str(time.time()))
> id=id.digest()
> id=string.strip(id)
> id=string.strip(base64.encodestring(id))
> id=quote(id[:-2])
> seq = string.hexdigits + string.lowercase + string.uppercase
> new_id = ''
> for l in id:
> if l == '/' or l == '%':
> new_id = new_id + choice(seq)
> else:
> new_id = new_id + l
> return new_id
>
>
> If anyone has a more elegant solution I would love to set my tired eyes
> on it. ;-)
>
> All my best,
Couldn't you use a combination of ZopeTime and a random integer in the
range 1-10000000? The whrandom module is available to _ I believe.
Pavlos