Пример #1
0
 def add_backend(self, name, module_name, config=None):
     """
     Find the backend named *module_name*, instantiate it, and add it
     to the dict of backends to be polled for incoming messages, once
     the router is started. Return the backend instance.
     """
     if not inspect.isclass(module_name):
         cls = BackendBase.find(module_name)
         if cls is None: return None
     else:
         cls = module_name
     config = self._clean_backend_config(config or {})
     backend = cls(self, name, **config)
     self.backends[name] = backend
     return backend
Пример #2
0
 def add_backend(self, name, module_name, config=None):
     """
     Find the backend named *module_name*, instantiate it, and add it
     to the dict of backends to be polled for incoming messages, once
     the router is started. Return the backend instance.
     """
     if not inspect.isclass(module_name):
         try:
             cls = BackendBase.find(module_name)
         except AttributeError:
             cls = None
     elif issubclass(module_name, BackendBase):
         cls = module_name
     if not cls:
         return None
     config = self._clean_backend_config(config or {})
     backend = cls(self, name, **config)
     self.backends[name] = backend
     return backend
Пример #3
0
    def add_backend(self, name, module_name, config=None):
        """
        Add RapidSMS backend to router. Installed backends will be used to
        send outgoing messages.

        :param name: Name of backend.
        :param module_name: :class:`BackendBase <rapidsms.backends.base.BackendBase>`
                            object or dotted path to backend class.
        :returns: :class:`BackendBase <rapidsms.backends.base.BackendBase>`
                  object if found, otherwise a ``ValueError`` exception
                  will be raised.
        """
        if isinstance(module_name, basestring):
            cls = BackendBase.find(module_name)
        elif issubclass(module_name, BackendBase):
            cls = module_name
        if not cls:
            raise ValueError('No such backend "%s"' % module_name)
        config = self._clean_backend_config(config or {})
        backend = cls(self, name, **config)
        self.backends[name] = backend
        return backend
Пример #4
0
    def add_backend(self, name, module_name, config=None):
        """
        Add RapidSMS backend to router. Installed backends will be used to
        send outgoing messages.

        :param name: Name of backend.
        :param module_name: :class:`BackendBase <rapidsms.backends.base.BackendBase>`
                            object or dotted path to backend class.
        :returns: :class:`BackendBase <rapidsms.backends.base.BackendBase>`
                  object if found, otherwise a ``ValueError`` exception
                  will be raised.
        """
        if isinstance(module_name, basestring):
            cls = BackendBase.find(module_name)
        elif issubclass(module_name, BackendBase):
            cls = module_name
        if not cls:
            raise ValueError('No such backend "%s"' % module_name)
        config = self._clean_backend_config(config or {})
        backend = cls(self, name, **config)
        self.backends[name] = backend
        return backend
Пример #5
0
 def test_backend_finds_valid_backend_class(self):
     """Class should be returned if valid."""
     backend = BackendBase.find('rapidsms.backends.test_base.TestBackend')
     self.assertEqual(TestBackend, backend)
Пример #6
0
def test_backend_finds_valid_backend_classes():
    backend = BackendBase.find('rapidsms.backends.kannel.outgoing')
    from rapidsms.backends.kannel.outgoing import KannelBackend
    assert_equals(backend, KannelBackend)
Пример #7
0
def test_backend_finds_valid_backend_classes():
    backend = BackendBase.find('rapidsms.backends.kannel.outgoing')
    from rapidsms.backends.kannel.outgoing import KannelBackend
    assert_equals(backend, KannelBackend)