コード例 #1
0
 def test_find_aliases_none(self):
     # dodgy IHasAlias marker
     alsoProvides(self.folder['d1'], IHasAlias)
     
     info = IAliasInformation(self.folder['d1'])
     aliases = list(info.findAliases())
     self.assertEquals(0, len(aliases))
コード例 #2
0
def rebroadcastModifiedEvent(obj, event):
    """When an object with an alias is modified, consider the alias modified
    as well. This will e.g. 
    """
    info = IAliasInformation(obj, None)
    if info is not None:
        for alias in info.findAliases():
            new_event = ObjectModifiedEvent(alias, *event.descriptions)
            notify(new_event)
コード例 #3
0
 def test_find_aliases_single(self):
     relation = RelationValue(self.intids.getId(self.folder['d1']))
     self.folder.invokeFactory('collective.alias', 'a1', _aliasTarget=relation)
     
     info = IAliasInformation(self.folder['d1'])
     
     aliases = list(info.findAliases())
     self.assertEquals(1, len(aliases))
     self.failUnless(aliases[0].aq_parent.aq_base is self.folder.aq_base)
     self.assertEquals(self.folder['a1'].getPhysicalPath(), aliases[0].getPhysicalPath())
コード例 #4
0
def removeAliasOnDelete(obj, event):
    """When an object with an alias is removed, remove all aliases as well.
    """
    info = IAliasInformation(event.object, None)
    if info is not None:
        
        # take off the marker interface now so that the handler for
        # (IAlias, IObjectRemovedEvent) doesn't try to go in circles
        noLongerProvides(event.object, IHasAlias)
        
        for alias in info.findAliases():
            parent = aq_parent(aq_inner(alias))
            parent._delObject(alias.getId())
コード例 #5
0
def removeAliasOnDelete(obj, event):
    """When an object with an alias is removed, remove all aliases as well.
    """
    info = IAliasInformation(event.object, None)
    if info is not None:

        # take off the marker interface now so that the handler for
        # (IAlias, IObjectRemovedEvent) doesn't try to go in circles
        noLongerProvides(event.object, IHasAlias)

        for alias in info.findAliases():
            parent = aq_parent(aq_inner(alias))
            parent._delObject(alias.getId())
コード例 #6
0
 def test_find_aliases_multiple(self):
     relation = RelationValue(self.intids.getId(self.folder['d1']))
     self.folder.invokeFactory('collective.alias', 'a1', _aliasTarget=relation)
     
     relation = RelationValue(self.intids.getId(self.folder['d1']))
     self.folder.invokeFactory('collective.alias', 'a2', _aliasTarget=relation)
     
     info = IAliasInformation(self.folder['d1'])
     
     aliases = list(info.findAliases())
     self.assertEquals(2, len(aliases))
     
     self.failUnless(aliases[0].aq_parent.aq_base is self.folder.aq_base)
     self.assertEquals(self.folder['a1'].getPhysicalPath(), aliases[0].getPhysicalPath())
     
     self.failUnless(aliases[1].aq_parent.aq_base is self.folder.aq_base)
     self.assertEquals(self.folder['a2'].getPhysicalPath(), aliases[1].getPhysicalPath())