def test_migrateTrackbacksForEntry_published(self):
        # Disabled because publishing the item broke the unittesting
        # mechanism somehow.

        # Modify the entry to have the old trackback attribute.
        existingURLs = ['http://sam.pl/e', 'http://example.org/reutel']
        existingURLs.sort()
        self.entry.trackbackURLs = existingURLs
        # Publish the entry.
        wftool = getToolByName(self.entry, 'portal_workflow')
        wftool.doActionFor(self.entry, 'publish')
        # Migrate and check the results.
        self.migration.migrateTrackbacksForEntry(self.entry)
        tbim = ITrackbackOutManager(self.entry)
        # Now we need to search for the pinged URLs.
        results = list(tbim.getPingedURLs())
        results.sort()
        self.assertEquals(existingURLs, results)
        # The trackbackURLS attribute should be gone.
        self.assertEquals(
            getattr(self.entry, 'trackbackURLs', 'way of the dodo'),
            'way of the dodo')
        # Migrate again, results should be the same.
        self.migration.migrateTrackbacksForEntry(self.entry)
        tbim = ITrackbackOutManager(self.entry)
        results = list(tbim.getPingedURLs())
        results.sort()
        self.assertEquals(existingURLs, results)
예제 #2
0
 def migrateTrackbacksForEntry(self, entry):
     """Swap to multiple trackback URLs stored with an adapter.
     """
     if not hasattr(entry, 'trackbackURLs'):
         # The attribute doesn't exist anymore so nothing to
         # migrate!
         return
     # Adapt to the interface for storing trackback details
     tbim = ITrackbackOutManager(entry)
     # Get the existing URLs by attribute access as the methods are no longer
     # available - the schema no longer defines them.
     urls = getattr(entry, 'trackbackURLs', None)
     if urls:
         #print >> self.out, \
         #    u"Migrating trackbacks for %s." % "/".join(entry.getPhysicalPath())
         wftool = getToolByName(entry, 'portal_workflow')
         review_state = wftool.getInfoFor(entry, 'review_state')
         if review_state == 'published':
             # If the entry is published, the URLs will already have been pinged
             tbim.setPingedURLs(urls)
         else:
             # ... otherwise, they still need to be pinged.
             tbim.setURLsToPing(urls)
     # Remove the attribute.
     del entry.trackbackURLs
 def test_migrateTrackbacksForEntry(self):
     # Modify the entry to have the old trackback attribute.
     existingURLs = ['http://sam.pl/e', 'http://example.org/reutel']
     existingURLs.sort()
     self.entry.trackbackURLs = existingURLs
     # Migrate and check the results.
     self.migration.migrateTrackbacksForEntry(self.entry)
     tbim = ITrackbackOutManager(self.entry)
     # We're not published, so check for the urls we still have to
     # ping.
     results = list(tbim.getURLsToPing())
     results.sort()
     self.assertEquals(existingURLs, results)
     # The trackbackURLS attribute should be gone.
     self.assertEquals(
         getattr(self.entry, 'trackbackURLs', 'way of the dodo'),
         'way of the dodo')
     # Migrate again, results should be the same.
     self.migration.migrateTrackbacksForEntry(self.entry)
     results = list(tbim.getURLsToPing())
     results.sort()
     self.assertEquals(existingURLs, results)