def review_verified_objects(settings, event):
    """Get the new entries on settings and apply them on verified objects"""
    new_entries = get_new_entries(event.oldValue, event.newValue)

    # if there's nothing new, we are done
    if not new_entries:
        return

    new_entries = '\n'.join(new_entries)

    catalog = api.portal.get_tool('portal_catalog')
    brains = catalog(object_provides=IStopWordsVerified.__identifier__)

    if not ASYNC:
        for brain in brains:
            verify_brain(brain, new_entries)
    else:
        # split the work to review the verified objects for new stop words in
        # batches
        batch = 1
        amount = 300
        count = len(brains)
        while count > 0:
            view_path = '/{0}/@@review-objects'.format(
                api.portal.get().id
            )
            params = {
                'start': amount * batch - amount,
                'size': amount,
                'entries': new_entries,
            }
            logger.warn('Queued request {0} {1}'.format(view_path, params))
            taskqueue.add(
                view_path,
                params=params
            )

            batch += 1
            count -= amount
 def test_something_minus_newline_characters(self):
     """What if the new list only removes newline characters"""
     self.assertEqual(
         get_new_entries('\n\n\n\none\ntwo\n\n\n\n', 'one\ntwo'),
         [],
     )
 def test_something_plus_some_minus_some_others(self):
     """What if the new list has new entries and some entries removed"""
     self.assertEqual(
         get_new_entries('one\ntwo\nthree\nfour', 'one\ntwo\nthree\nfive'),
         [u'five', ],
     )
 def test_something_to_same_something_but_different_order(self):
     """What if both lists have the same entries but ordered differently"""
     self.assertEqual(
         get_new_entries('one\ntwo\nthree\nfour', 'three\none\nfour\ntwo'),
         [],
     )
 def test_something_plus_newline_characters(self):
     """What if the new list only adds newline characters"""
     self.assertEqual(
         get_new_entries('one\ntwo', '\n\n\n\none\ntwo\n\n\n\n'),
         [],
     )
 def test_something_plus_new_entries(self):
     """What if the new list has some new entries"""
     self.assertEqual(
         get_new_entries('one\ntwo', 'one\ntwo\nthree\nfour'),
         ['four', 'three', ],
     )
 def test_something_minus_some_entries(self):
     """What if the new list has removed some entries"""
     self.assertEqual(
         get_new_entries('one\ntwo\nthree\nfour', 'one\ntwo'),
         [],
     )
 def test_something_to_same_something(self):
     """What if both, none empty, lists are the same"""
     self.assertEqual(
         get_new_entries('one\ntwo', 'one\ntwo'),
         [],
     )
 def test_none_to_only_newlines(self):
     """What if the list was empty and now has only newline characters"""
     self.assertEqual(
         get_new_entries(None, '\n\n\n\n'),
         [],
     )
 def test_none_to_something(self):
     """What if the list was empty and now has some entries"""
     self.assertEqual(
         get_new_entries(None, 'one\ntwo'),
         ['one', 'two', ],
     )
 def test_something_to_none(self):
     """What if the list gets empty"""
     self.assertEqual(
         get_new_entries('one\ntwo', None),
         [],
     )
 def test_none_to_none(self):
     """What if both lists are none"""
     self.assertEqual(
         get_new_entries(None, None),
         [],
     )