[Seaside] How generate ID

Philippe Marschall philippe.marschall at gmail.com
Sun Dec 30 21:29:36 UTC 2007


2007/12/30, Nevin Pratt <nevin at bountifulbaby.com>:
> John M McIntosh wrote:
> > Assuming you want a unique value, and you don't care if it's in order
> > then you can just do
> >
> > UUID new
> > -> e0090895-4a12-4ef6-82e0-9acefc76ff9c  -> asString36  ->
> > '9alvh9w807elbql3xdq6l05pc'
> >
> > that will be unique.
> >
> > buf if you must start at 1 and go to infinity then you need to bother
> > with
> > Semaphore forMutualExclusion
> > and do things like remember what the last number was...
> > more code and options to get it wrong.
> >
>
> Thread safety might not matter.
>
> For example, my site bountifulbaby.com uses the technique Tom suggests,
> via a class variable and a #newID class method, to generate product item
> numbers whenever we add a new product for sale on the website.
>
> Adding a new product for sale is only done via the Administrator page.
> The risk of two different people here at Bountiful Baby both adding a
> new product to the website at the exact same time is virtually nil.

Yeah right. Kinda remembers me of "that vulnerability is completely
theoretical".

Cheers
Philippe

> I would also venture a guess that if any other Seaside app wants a
> serially increasing ID like that, there is a pretty good chance it
> likewise would only be accessed from an Admin page, and the risk of two
> people doing it at the exact same time is likewise virtually nil.
>
> Obviously there are exceptions, but Jakub might not need to worry about
> thread safety.
>
> It just depends on what he is doing it for.
>
> Nevin
>
>
>
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>


More information about the seaside mailing list