示例#1
0
 def setUp(self):
     params = {
         'title': 'My nodetype',
         'content': 'My content',
         'tags': 'gstudio, test',
         'slug': 'my-nodetype'
     }
     self.nodetype = Nodetype.objects.create(**params)
     self.pinger = DirectoryPinger('http://localhost', [self.nodetype],
                                   start_now=False)
示例#2
0
 def setUp(self):
     params = {'title': 'My nodetype',
               'content': 'My content',
               'tags': 'gstudio, test',
               'slug': 'my-nodetype'}
     self.nodetype = Nodetype.objects.create(**params)
     self.pinger = DirectoryPinger('http://localhost', [self.nodetype],
                                   start_now=False)
示例#3
0
def ping_directories_handler(sender, **kwargs):
    """Ping Directories when a nodetype is saved"""
    nodetype = kwargs['instance']

    if nodetype.is_visible and settings.SAVE_PING_DIRECTORIES:
        from gstudio.ping import DirectoryPinger

        for directory in settings.PING_DIRECTORIES:
            DirectoryPinger(directory, [nodetype])
示例#4
0
 def ping_directories(self, request, queryset, messages=True):
     """Ping Directories for selected relationtypes"""
     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 relationtypes.') %
                     {'directory': directory, 'success': success})
 def ping_directories(self, request, queryset, messages=True):
     """Ping Directories for selected processtypes"""
     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 processtypes.') %
                     {'directory': directory, 'success': success})
示例#6
0
class DirectoryPingerTestCase(TestCase):
    """Test cases for DirectoryPinger"""
    def setUp(self):
        params = {'title': 'My nodetype',
                  'content': 'My content',
                  'tags': 'gstudio, test',
                  'slug': 'my-nodetype'}
        self.nodetype = Nodetype.objects.create(**params)
        self.pinger = DirectoryPinger('http://localhost', [self.nodetype],
                                      start_now=False)

    def test_ping_nodetype(self):
        self.assertEquals(
            self.pinger.ping_nodetype(self.nodetype),
            {'message': 'http://localhost is an invalid directory.',
             'flerror': True})
示例#7
0
class DirectoryPingerTestCase(TestCase):
    """Test cases for DirectoryPinger"""
    def setUp(self):
        params = {
            'title': 'My nodetype',
            'content': 'My content',
            'tags': 'gstudio, test',
            'slug': 'my-nodetype'
        }
        self.nodetype = Nodetype.objects.create(**params)
        self.pinger = DirectoryPinger('http://localhost', [self.nodetype],
                                      start_now=False)

    def test_ping_nodetype(self):
        self.assertEquals(
            self.pinger.ping_nodetype(self.nodetype), {
                'message': 'http://localhost is an invalid directory.',
                'flerror': True
            })