Пример #1
0
 def test_has_alias_clone_loses_marker(self):
     self.failUnless(IHasAlias.providedBy(self.folder['d1']))
     cp = self.folder.manage_copyObjects('d1')
     result = self.folder.manage_pasteObjects(cp)
     self.assertEquals(1, len(result))
     newId = result[0]['new_id']
     self.failUnless(IHasAlias.providedBy(self.folder['d1']))
     self.failIf(IHasAlias.providedBy(self.folder[newId]))
 def test_has_alias_clone_loses_marker(self):
     self.failUnless(IHasAlias.providedBy(self.folder['d1']))
     cp = self.folder.manage_copyObjects('d1')
     result = self.folder.manage_pasteObjects(cp)
     self.assertEquals(1, len(result))
     newId = result[0]['new_id']
     self.failUnless(IHasAlias.providedBy(self.folder['d1']))
     self.failIf(IHasAlias.providedBy(self.folder[newId]))
 def test_has_alias_counter_down(self):
     relation = RelationValue(self.intids.getId(self.folder['d1']))
     self.folder.invokeFactory('collective.alias', 'a2', _aliasTarget=relation)
     
     self.failUnless(IHasAlias.providedBy(self.folder['d1']))
     self.folder._delObject('a2')
     self.failUnless(IHasAlias.providedBy(self.folder['d1']))
     self.folder._delObject('a1')
     self.failIf(IHasAlias.providedBy(self.folder['d1']))
Пример #4
0
    def test_has_alias_counter_down(self):
        relation = RelationValue(self.intids.getId(self.folder['d1']))
        self.folder.invokeFactory('collective.alias',
                                  'a2',
                                  _aliasTarget=relation)

        self.failUnless(IHasAlias.providedBy(self.folder['d1']))
        self.folder._delObject('a2')
        self.failUnless(IHasAlias.providedBy(self.folder['d1']))
        self.folder._delObject('a1')
        self.failIf(IHasAlias.providedBy(self.folder['d1']))
def markTargetOnAdd(alias, event):
    """When the alias is added, mark the target with IHasAlias
    """
    
    target = aq_inner(alias._target)
    if target is not None and not IHasAlias.providedBy(target):
        alsoProvides(target, IHasAlias)
def unmarkTargetOnRemove(alias, event):
    """When the alias is created, 
    """
    target = aq_inner(alias._target)
    if target is not None and IHasAlias.providedBy(target):
        
        intids = queryUtility(IIntIds)
        catalog = queryUtility(ICatalog)
        
        if intids is not None and catalog is not None:
            
            try:
                to_id = intids.getId(target)
            except KeyError:
                logger.error("Alias target %s does not have an intid" % target)
                return
            
            alias_base = aq_base(alias)
            
            for rel in catalog.findRelations({
                'to_id': to_id,
                'from_interfaces_flattened': IAlias,
                'from_attribute': '_aliasTarget',
            }):
                # abort if there is another alias
                if alias_base is not rel.from_object:
                    return
        
        noLongerProvides(target, IHasAlias)
Пример #7
0
def unmarkTargetOnRemove(alias, event):
    """When the alias is created,
    """
    try:
        target = aq_inner(alias._target)
    except ComponentLookupError:
        target = None
    if target is not None and IHasAlias.providedBy(target):

        intids = queryUtility(IIntIds)
        catalog = queryUtility(ICatalog)

        if intids is not None and catalog is not None:

            try:
                to_id = intids.getId(target)
            except KeyError:
                logger.error("Alias target %s does not have an intid" % target)
                return

            alias_base = aq_base(alias)

            for rel in catalog.findRelations({
                    'to_id': to_id,
                    'from_interfaces_flattened': IAlias,
                    'from_attribute': '_aliasTarget',
            }):
                # abort if there is another alias
                if alias_base is not rel.from_object:
                    return

        noLongerProvides(target, IHasAlias)
Пример #8
0
def markTargetOnAdd(alias, event):
    """When the alias is added, mark the target with IHasAlias
    """

    target = aq_inner(alias._target)
    if target is not None and not IHasAlias.providedBy(target):
        alsoProvides(target, IHasAlias)
 def test_has_alias(self):
     self.folder.invokeFactory('Document', 'd2')
     self.failIf(IHasAlias.providedBy(self.folder['d2']))
     self.failUnless(IHasAlias.providedBy(self.folder['d1']))
 def test_has_alias_removed_on_delete(self):
     self.failUnless(IHasAlias.providedBy(self.folder['d1']))
     self.folder._delObject('a1')
     self.failIf(IHasAlias.providedBy(self.folder['d1']))
Пример #11
0
 def test_has_alias_removed_on_delete(self):
     self.failUnless(IHasAlias.providedBy(self.folder['d1']))
     self.folder._delObject('a1')
     self.failIf(IHasAlias.providedBy(self.folder['d1']))
Пример #12
0
 def test_has_alias(self):
     self.folder.invokeFactory('Document', 'd2')
     self.failIf(IHasAlias.providedBy(self.folder['d2']))
     self.failUnless(IHasAlias.providedBy(self.folder['d1']))