def _get_source(self):
     c = self.aq_inner.aq_parent
     while True:
         if INewsPublication.providedBy(c):
             return c
         if IRoot.providedBy(c):
             return None
         c = c.aq_parent
     return None
 def upgrade(self, content):
     logger.info(u"Upgrade News Filter %s.", content_path(content))
     root = content.get_root()
     for source in content._sources:
         try:
             target = root.unrestrictedTraverse(source)
         except (AttributeError, KeyError, NotFound, TypeError):
             logger.error(u"Could not find content %s for News Filter %s.", source, content_path(content))
             continue
         if INewsPublication.providedBy(target):
             content.add_source(target)
         else:
             logger.error(
                 u"Content type %s is not an allowed source for %s.", content_path(target), content_path(content)
             )
     del content._sources
     return content
 def upgrade(self, content):
     logger.info(u"Upgrade News Filter %s.", content_path(content))
     root = content.get_root()
     for source in content._sources:
         try:
             target = root.unrestrictedTraverse(source)
         except (AttributeError, KeyError, NotFound, TypeError):
             logger.error(u'Could not find content %s for News Filter %s.',
                          source, content_path(content))
             continue
         if INewsPublication.providedBy(target):
             content.add_source(target)
         else:
             logger.error(
                 u'Content type %s is not an allowed source for %s.',
                 content_path(target), content_path(content))
     del content._sources
     return content