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

Jason Spisak 444@hiretechs.com
Thu, 09 Mar 2000 16:58:58 GMT


Ross,

On my dual SMP PII 350 I still only create 48 objects using this short code
per second. 

<dtml-var standard_html_header>
<dtml-in "_.range(0,1000)">
 <dtml-with "ClientClass.createInObjectManager(_.getitem('unique_id',1),
REQUEST)">
 <dtml-var id>
 </dtml-with>
</dtml-in>
<dtml-var standard_html_footer>
 _.float works terrific.  I suppose a blend of the two techniques would
give a pretty solid id, even on very fast parallel machines, because they
would have to get the same random number from a large amount of
possiblities in under a millisecond. Thanks for both your help on this.


<dtml-var "_.str(_.float(ZopeTime())) +    
_.str(_.whrandom.randint(1,100000))">


All my best,


Ross Lazarus writes:

> ZopeTime() to float to string conversion works even better since you get
> milliseconds - there is always the risk that in an SMP processor
> environment, you JUST might get bitten, but that's also true of any
> hash algorithm - you're down to probabilities which are exceedingly
> small.
> 
> Of course, you could enclose your new id generating code (hash or float
> time) in some loop which checks to see if an object with that id
> exists, if it does, wait a small random time, and add a letter to the
> end of the string, retest and loop until it IS unique, then create the
> object. The time taken to do all that means you could be "safe" from
> multiple processors doing precisely the same thing at precisely the
> same time..
> 
> jason spisak <44-@hiretechs.com> wrote: 
> original article:http://www.egroups.com/group/zope/?start=25478
> > Zopsters,
> > 
> > numbers, employee numbers, etc...) so I don't like to use a counter
> for
> > ids.  The ZopeTime() to int to string conversion works unless you are
> > programatically creating multiple items in the same folder, and have a
> > descent processor.  I have derived the following bad hack from the
> code
> 
> 


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.