コード例 #1
0
 def test_run(self):
     pinger = DirectoryPinger('http://localhost', [self.entry])
     pinger.run()
     self.assertEqual(
         pinger.results,
         [{'flerror': True,
           'message': 'http://localhost is an invalid directory.'}])
コード例 #2
0
 def test_ping_entry(self):
     pinger = DirectoryPinger('http://localhost', [self.entry])
     self.assertEqual(
         pinger.ping_entry(self.entry),
         {'message': 'http://localhost is an invalid directory.',
          'flerror': True})
     self.assertEqual(pinger.results, [])
コード例 #3
0
ファイル: ping.py プロジェクト: zapier/django-blog-zinnia
 def setUp(self):
     params = {'title': 'My entry',
               'content': 'My content',
               'tags': 'zinnia, test',
               'slug': 'my-entry'}
     self.entry = Entry.objects.create(**params)
     self.pinger = DirectoryPinger('http://localhost', [self.entry],
                                   start_now=False)
コード例 #4
0
ファイル: admin.py プロジェクト: barbarae/kipp
 def ping_directories(self, request, queryset):
     """Ping Directories for selected entries"""
     success = 0
     for directory in PING_DIRECTORIES:
         pinger = DirectoryPinger(directory)
         for entry in queryset:
             response = pinger.ping(entry)
             if not response.get('flerror', True):
                 success += 1
     self.message_user(request, _('%i directories succesfully pinged.') % success)
コード例 #5
0
 def ping_directories(self, request, queryset):
     """Ping Directories for selected entries"""
     for directory in settings.PING_DIRECTORIES:
         pinger = DirectoryPinger(directory, queryset)
         pinger.join()
         success = 0
         for result in pinger.results:
             if not result.get('flerror', True):
                 success += 1
             else:
                 self.message_user(request, '%s : %s' % (directory, result['message']))
         if success:
             self.message_user(request, _('%s directory succesfully pinged %d entries.') % (directory, success))
コード例 #6
0
ファイル: entry.py プロジェクト: strogo/django-blog-zinnia
 def ping_directories(self, request, queryset):
     """Ping Directories for selected entries"""
     for directory in settings.PING_DIRECTORIES:
         pinger = DirectoryPinger(directory, queryset)
         pinger.join()
         success = 0
         for result in pinger.results:
             if not result.get("flerror", True):
                 success += 1
             else:
                 self.message_user(request, "%s : %s" % (directory, result["message"]))
         if success:
             self.message_user(
                 request,
                 _("%(directory)s directory succesfully " "pinged %(success)d entries.")
                 % {"directory": directory, "success": success},
             )
コード例 #7
0
def ping_directories_handler(sender, **kwargs):
    """Ping Directories when an entry is saved"""
    entry = kwargs['instance']

    if entry.is_visible and settings.SAVE_PING_DIRECTORIES:
        from zinnia.ping import DirectoryPinger

        for directory in settings.PING_DIRECTORIES:
            DirectoryPinger(directory, [entry])
コード例 #8
0
ファイル: entry.py プロジェクト: bopopescu/mp100
 def ping_directories(self, request, queryset, messages=True):
     """Ping Directories for selected entries"""
     for directory in settings.PING_DIRECTORIES:
         pinger = DirectoryPinger(directory, queryset)
         pinger.join()
         if messages:
             success = 0
             for result in pinger.results:
                 if not result.get('flerror', True):
                     success += 1
                 else:
                     self.message_user(
                         request,
                         '%s : %s' % (directory, result['message']))
             if success:
                 self.message_user(request,
                                   _('%(directory)s directory succesfully ' \
                                     'pinged %(success)d entries.') %
                                   {'directory': directory, 'success': success})
コード例 #9
0
 def ping_directories(self, request, queryset, messages=True):
     """
     Ping web directories for selected entries.
     """
     for directory in settings.PING_DIRECTORIES:
         pinger = DirectoryPinger(directory, queryset)
         pinger.join()
         if messages:
             success = 0
             for result in pinger.results:
                 if not result.get('flerror', True):
                     success += 1
                 else:
                     self.message_user(request,
                                       '%s : %s' % (directory,
                                                    result['message']))
             if success:
                 self.message_user(
                     request,
                     _('%(directory)s directory succesfully '
                       'pinged %(success)d entries.') %
                     {'directory': directory, 'success': success})
コード例 #10
0
ファイル: ping.py プロジェクト: zapier/django-blog-zinnia
class DirectoryPingerTestCase(TestCase):
    """Test cases for DirectoryPinger"""
    def setUp(self):
        params = {'title': 'My entry',
                  'content': 'My content',
                  'tags': 'zinnia, test',
                  'slug': 'my-entry'}
        self.entry = Entry.objects.create(**params)
        self.pinger = DirectoryPinger('http://localhost', [self.entry],
                                      start_now=False)

    def test_ping_entry(self):
        self.assertEquals(
            self.pinger.ping_entry(self.entry),
            {'message': 'http://localhost is an invalid directory.',
             'flerror': True})