[Zope-CMF] Bug with CMFUid content when copied indirectly and some confusion.

Gregoire Weber gregweb at gmx.ch
Wed Aug 25 05:10:53 EDT 2004


Thanks Tim!

There is definitely a bug. There is a short term fix for CMFUid but it
seems the real cause (and bug) lives in CMFCatalogAware. There seems to
be a problem with the handling of opaque items (non SimpleItems).

I'm currently investigating on that. 

Tres: A e-mail about the behaviour of __recurse calling opaque items
      will follow today.

Gregoire

My answers to your questions:

At 14:33 25.08.2004 +0800, Tim Hoffman wrote:
>I am exploring/testing the CMFUid functionality of the new CMF 1.5.0 Beta,
>(I have been using my own Uid tool for some time, but it 
>relied on the use of a monkey patch which added a mixin class to 
>all PortalContent and PortalFolder plus a few others to ensure that all
>CMFContent automgically got unique ids and  managment and control of the
>uid generation (especially after copying ;-) could be enforced.
> 
>This approach is a support nightmare however, so I have always been
>looking for a more supportable  mechanism hence the investigation of
>CMFUid.)

CMFUid enforces that in marking the annotation object as 'ICallableOpaqueItem'
(see 'IUniqueIdAnnotation' in interfaces.py). This way it gets called on
copying and can destroy itself.

>Anyway I am trying to fathom exactly how CMFUid works and have a couple
>of questions. (plus I have noticed what I believe to be a bug)
>
>As I understand it, a call to uidtool.register(object) is in main
>template. This gets called and if the object doesn't have a uid a new uid
>(UniqueIdAnnotion instance) is created and stored as an attribute 
>if the content object (currently named cmf_uid).  (UniqueIdAnnotation has
>manage_afterAdd and manage_afterClone methods etc).  So far so good.

Ok.

>However I don't understand how the manage_afterAdd/Clone methods get
>called.
> 
>A normal content object has manage_afterClone/Add by virtue of
>ultimately subclassing things like ObjectManager/CatalogAware (CopySupport
>Mixin) etc.
>
>But all of these methods iterate  over result of objectValues() calling
>manage_afterClone,manage_afterAdd on each as appropriate. 
>
>But becuase the UniqueIdAnnotation is stored as an attribute calling
>contentValues on a content object that has a uid doesn't return
>the UniqueIdAnnotation object (it isn't based on
>SimpleContent/ObjectManager but Persistent and Implicit). 
>
>SO I am a bit confused how when one copies a content object how the
>uid is being updated. As I can't find anything that might call
>object.cmf_uid.manage_afterClone/Add and cmf_uid will never be
>returned from a call to objectValues(). Am I missing something here?

'cmf_uid' get's called by the 'opaqueItems' method in CMFCatalogAware.py 
in CMFCore because it is marked withe the 'ICallableOpaqueItem' interface.

This is new in CMF 1.5 also (I integrated that in to CMFCore this january).

>Now I come to the bug I think I have encountered. 
>If you copy a folder with content, the contained contents UID's 
>do not get updated ending up with duplicate UID's. Which I believe is a
>bug. If you copy the content directly the uid does get updated.

Uuups! See above.



More information about the Zope-CMF mailing list