Back to index

plone3  3.1.7
Classes | Functions
CMFUid.UniqueIdAnnotationTool Namespace Reference

Classes

class  UniqueIdAnnotation
class  UniqueIdAnnotationTool

Functions

def handleUidAnnotationEvent

Function Documentation

Event subscriber for (IUniqueIdAnnotation, IObjectEvent) events

Definition at line 72 of file UniqueIdAnnotationTool.py.

00072 
00073 def handleUidAnnotationEvent(ob, event):
00074     """ Event subscriber for (IUniqueIdAnnotation, IObjectEvent) events
00075     """
00076 
00077     if IObjectAddedEvent.providedBy(event):
00078         if event.newParent is not None:
00079             anno_tool = queryUtility(IUniqueIdAnnotationManagement)
00080             uid_handler = getToolByName(ob, 'portal_uidhandler', None)
00081             if anno_tool is not None:
00082                 remove_on_add = anno_tool.getProperty('remove_on_add',False)
00083                 remove_on_clone = anno_tool.getProperty('remove_on_clone',False)
00084                 assign_on_add = anno_tool.getProperty('assign_on_add',False)
00085 
00086                 if (remove_on_add and remove_on_clone) or assign_on_add:
00087                     try:
00088                         uid_handler.unregister(ob)
00089                     except UniqueIdError:
00090                         # did not have one
00091                         pass
00092                 if assign_on_add:
00093                     # assign new uid
00094                     uid_handler.register(ob)
00095                  
00096     elif IObjectClonedEvent.providedBy(event):
00097         anno_tool = queryUtility(IUniqueIdAnnotationManagement)
00098         uid_handler = getToolByName(ob, 'portal_uidhandler', None)
00099 
00100         if anno_tool is not None:
00101             remove_on_clone = anno_tool.getProperty('remove_on_clone', False)
00102             assign_on_clone = anno_tool.getProperty('assign_on_clone', False)
00103             if remove_on_clone or assign_on_clone:
00104                 try:
00105                     uid_handler.unregister(ob)
00106                 except UniqueIdError:
00107                     # did not have one
00108                     pass
00109             if assign_on_clone:
00110                 # assign new uid
00111                 uid_handler.register(ob)
        

Here is the call graph for this function: