[Zope3-Users] Re: RFC 4122 UUIDs

Derek Richardson derek.richardson at gatech.edu
Thu Apr 5 15:02:59 EDT 2007


Martin Aspeli wrote:
> 
> 
> 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)
>>
> 
> Look at zope.intid; it should be IObjectCreatedEvent or IObjectAddedEvent.
> 
> Martin
> 

I have started coding a uuid package for Zope. zope.intid uses 
IObjectAddedEvent; I plan to as well.

However, the uuid differs from the intid in that I want to store the 
uuid on the object, rather than in a utility. This will ensure that 
uuids travel with their objects without having to modify import/export 
or other code. My initial idea is to use an annotation, but I'm not sure 
this is right. I'll have to annotate all the content classes in the 
system, which seems to be a *huge* zcml pain. Any advice for avoiding this?

Thanks,

Derek



More information about the Zope3-users mailing list