[Seaside] How generate ID
Nevin Pratt
nevin at bountifulbaby.com
Mon Dec 31 00:06:04 UTC 2007
Philippe Marschall wrote:
> 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
>
>
DTSTTCPW
Do The Simplest Thing That Could Possibly Work.
For a long time, I was the only person that even had the password to the
Bountiful Baby admin page.
And even with a few more people now, I would still maintain that 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. And
even if it happened (which it won't), the only harm done is the second
item would have to be added again.
So again, I would say that whether or not a sequential ID needs the
overhead of a protection semaphore depends on what it is being used for.
Nevin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20071230/d6782556/attachment-0001.htm
More information about the seaside
mailing list