Пример #1
0
    def get_pushers(self, settings, defaults):
        '''
        Setup the push class - storage for all things related to a specific subscriber channel (meaning an endpoint)
        '''
        push_list = []
        for destination in sorted(settings, key=lambda k: k['priority']):
            if destination['enabled'] == False:
                continue
            if self.message_type is None or self.message_type not in destination['endpoints']:
                raise ImproperlyConfigured("Endpoint type isn't registered")
            if self.namespace == '' or self.namespace is None:
                raise ImproperlyConfigured("Namespace isn't configured")
            if self.dossier == '' or self.dossier is None:
                raise ImproperlyConfigured("Dossier isn't configured")

            endpoint = destination['endpoints'][self.message_type]

            p = Push(destination['host'], endpoint['path'],
                     self.namespace,
                     self.dossier,
                     destination['subscriberName'],
                     destination['https'] if 'https' in destination else False)
            p.alias = destination.get('alias', destination['host'])
            p.fail_on_failure = destination.get('failOnFailure', True)
            p.debug = destination.get('debug', defaults.get('debug', False))
            p.timeout = destination.get('timeout', defaults.get('timeout', False))
            push_list.append(p)
        return push_list