[Zope3-Users] Re: RFC 4122 UUIDs
Paul Bugni
pbugni at u.washington.edu
Wed Apr 4 14:31:42 EDT 2007
Derek Richardson and I were just discussing this matter on freenode #vice
... I have no idea at this point if the suggested event model is better,
but it seems like an implementation that safely handles the missing
annotation on request, would be simpler and more efficient.
In other words, rather than listening for the creation event, why not
provide an interface that can be adapted to any object - where the
implementation assumes objects may not yet have a UUID stored as an
annotation. When the first request comes in, if none is found, you
generate it and annotate and persist the object then. I would think as
long as this implementation catches the potential write conflict error,
and handles by re-requesting the UUID annotation, the race case should
also be eliminated.
Flaws with this line of thinking?
Cheers,
Paul
Derek Richardson-2 wrote:
Martin Aspeli wrote:
>
>
> Stephan Richter-2 wrote:
>> On Wednesday 04 April 2007 13:06, Derek Richardson wrote:
>>> I am hoping that Zope 3 assigns an RFC 4122 UUID to each content item.
>>> If not, I am hoping there is a third-party product to do this.
>> No there is neither. We have an intid utility that guarantees
System-wide
>> unique ids. This utility is used at several places most notably the
>> catalog.
>>
>>> I would like RFC 4122 UUIDs to provide standard Atom feeds of Zope
>>> content [1].
>>>
>>> It will be better if Zope itself assigns UUIDs, so that there is a
>>> single source and not a possibility of multiple packages assigning
>>> different UUIDs to the same content item.
>> You have to write your own utility to generate the UUID. I checked the
RFC
>> quickly and our IntIds are certainly not of the format requested by RFC
>> 4122.
>>
>
> Presumably, the intid implementation would be a useful reference for
such a
> utility, and this would a good canidate for a general, re-usable
package.
>
> Martin
Good. I would like to write it as a general, re-usable package.
Generating RFC 4122 UUIDs is easy - there's a routine for it in the
python 2.5 standard libraries and a python 2.3+ version here:
http://zesty.ca/python/uuid.html
What seems more difficult is how to plug the routine in so that all
content items receive one and only one UUID upon creation. Maybe listen
for IObjectCreatedEvent and annotate then? Or is there a potential race
condition that means events are not the way to go?
(Unsure of the depths of Zope 3's architecture)
More information about the Zope3-users
mailing list