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

Jason Spisak 444@hiretechs.com
Thu, 09 Mar 2000 15:57:51 GMT


That sounds like a more elegant descision.  I don't know why, but something
in me said that a wholelly random sting needed to be generated.  Really
only the last integer conflicts.  Boy was I tired last night 8-|

Thanks again,


Pavlos Christoforou writes:

> 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
> 


Jason Spisak
CIO
HireTechs.com
6151 West Century Boulevard
Suite 900
Los Angeles, CA 90045
P. 310.665.3444
F. 310.665.3544

Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email
address may not be added to any commercial mail list with out my
permission.  Violation of my privacy with advertising or SPAM will
result in a suit for a MINIMUM of $500 damages/incident, $1500 for
repeats.