Back to index

plone3  3.1.7
Functions
plone.app.redirector.subscribers Namespace Reference

Functions

def objectMoved
def objectRemoved

Function Documentation

Tell the redirection storage that an object moved

Definition at line 7 of file subscribers.py.

00007 
00008 def objectMoved(obj, event):
00009     """Tell the redirection storage that an object moved
00010     """
00011 
00012     # Unfortunately, IObjectMoved is a rather generic event...
00013     if event.oldParent is not None and event.newParent is not None and event.oldName is not None:
00014         storage = queryUtility(IRedirectionStorage)
00015         if storage is not None:
00016             old_path = "%s/%s" % ('/'.join(event.oldParent.getPhysicalPath()), event.oldName,)
00017             new_path = '/'.join(obj.getPhysicalPath())
00018 
00019             # This event gets redispatched to children, and we should keep track of them as well
00020             # In this case, event.object is not the same as obj, and the old_path should actually
00021             # include obj.id
00022 
00023             if aq_base(event.object) is not aq_base(obj):
00024                 new_path_of_moved = '/'.join(event.object.getPhysicalPath())
00025                 old_path = old_path + new_path[len(new_path_of_moved):]
00026 
00027             # XXX: Special case - don't remember anything happening inside portal_factory
00028             if '/portal_factory/' in old_path:
00029                 return
00030 
00031             # Special case: don't remember object when it was just created...
00032             putils = getToolByName(obj, 'plone_utils')
00033             if putils is not None and putils.isIDAutoGenerated(event.oldName):
00034                 request = getattr(obj, 'REQUEST', None)
00035                 if request is not None:
00036                     url = request['ACTUAL_URL'].split('/')
00037                     if 'portal_factory' in url and event.oldName in url:
00038                         return
00039 
00040             storage.add(old_path, new_path)

Here is the call graph for this function:

Tell the redirection storage that the object was removed

Definition at line 41 of file subscribers.py.

00041 
00042 def objectRemoved(obj, event):
00043     """Tell the redirection storage that the object was removed
00044     """
00045     storage = queryUtility(IRedirectionStorage)
00046     if storage is not None:
00047         path = '/'.join(obj.getPhysicalPath())
00048         storage.destroy(path)