Пример #1
0
    def testDefaultPrimaryImplicatorMultipleRefsPerTriple(self):
        # This test requires the dpunktnpunkt-multipleref branch of
        # Archetypes to work
        from Products.Relations import config
        config.ALLOW_MULTIPLE_REFS_PER_TRIPLE = True

        ref_ctl = getToolByName(self.portal, REFERENCE_CATALOG)

        impl = rulesetmodule.DefaultPrimaryImplicator(self.ruleset)

        # connect 0 and 1
        ref = impl.connect(self.brains[0], self.brains[1])
        self.assertNotEquals(ref, None)
        brains = ref_ctl(sourceUID=self.brains[0].UID,
                         targetUID=self.brains[1].UID,
                         relationship=self.ruleset.getId())
        self.assertEquals(len(brains), 1)
        self.assertEquals(ref, brains[0].getObject())

        # now do the same again, connect must returns another ref now
        ref2 = impl.connect(self.brains[0], self.brains[1])
        self.assertNotEquals(ref2, None)

        # Now two references with the sample source, target and
        # relationship live in the catalog
        brains = ref_ctl(sourceUID=self.brains[0].UID,
                         targetUID=self.brains[1].UID,
                         relationship=self.ruleset.getId())
        self.assertEquals(len(brains), 2)
        ref_uids = [b.UID for b in brains]
        self.failUnless(ref.UID() in ref_uids)
        self.failUnless(ref2.UID() in ref_uids)

        config.ALLOW_MULTIPLE_REFS_PER_TRIPLE = False
Пример #2
0
    def testDefaultPrimaryImplicator(self):
        ref_ctl = getToolByName(self.portal, REFERENCE_CATALOG)

        impl = rulesetmodule.DefaultPrimaryImplicator(self.ruleset)

        # connect 0 and 1
        ref = impl.connect(self.brains[0], self.brains[1])
        self.assertNotEquals(ref, None)
        brains = ref_ctl(sourceUID=self.brains[0].UID,
                         targetUID=self.brains[1].UID,
                         relationship=self.ruleset.getId())
        self.assertEquals(len(brains), 1)
        self.assertEquals(ref, brains[0].getObject())

        # now do the same again, connect must returns another ref now
        ref2 = impl.connect(self.brains[0], self.brains[1])
        self.assertNotEquals(ref2, None)

        # Only one reference lives in the catalog, the other one was
        # 'updated'
        brains = ref_ctl(sourceUID=self.brains[0].UID,
                         targetUID=self.brains[1].UID,
                         relationship=self.ruleset.getId())
        self.assertEquals(len(brains), 1)
Пример #3
0
 def disconnect(self, reference):
     ruleset = self.getRuleset()
     self.calls['disconnect'].append((ruleset, reference))
     impl = rulesetmodule.DefaultPrimaryImplicator(ruleset)
     return impl.disconnect(reference)
Пример #4
0
 def connect(self, source, target, metadata=None):
     self.calls['connect'].append((source, target, metadata))
     impl = rulesetmodule.DefaultPrimaryImplicator(self.getRuleset())
     return impl.connect(source, target, metadata)
Пример #5
0
 def disconnect(self, reference):
     impl = ruleset.DefaultPrimaryImplicator(self.getRuleset())
     return impl.disconnect(reference)
Пример #6
0
 def connect(self, source, target, metadata=None):
     impl = ruleset.DefaultPrimaryImplicator(self.getRuleset())
     impl.referenceClass = ContentReference
     return impl.connect(source, target, metadata)