Пример #1
0
    def init(self):
        plain_http_config = MultiDict()
        soap_config = MultiDict()
        
        dol = deepcopy(self.worker_config.http_soap).dict_of_lists()
        
        for url_path in dol:
            for item in dol[url_path]:
                for soap_action, channel_info in item.items():
                    if channel_info['connection'] == 'channel':
                        if channel_info.transport == 'plain_http':
                            config = plain_http_config.setdefault(url_path, Bunch())
                            config[soap_action] = deepcopy(channel_info)
                        else:
                            config = soap_config.setdefault(url_path, Bunch())
                            config[soap_action] = deepcopy(channel_info)
                
        self.request_dispatcher = RequestDispatcher(simple_io_config=self.worker_config.simple_io)
        self.request_dispatcher.soap_handler = SOAPHandler(soap_config, self.server)
        self.request_dispatcher.plain_http_handler = PlainHTTPHandler(plain_http_config, self.server)
        
        # Statistics maintenance
        self.stats_maint = MaintenanceTool(self.kvdb.conn)

        self.request_dispatcher.security = ConnectionHTTPSOAPSecurity(
            self.server.odb.get_url_security(self.server.cluster_id, 'channel')[0],
            self.worker_config.basic_auth, self.worker_config.tech_acc, self.worker_config.wss)
        
        # Create all the expected connections
        self.init_sql()
        self.init_ftp()
        self.init_http_soap()
Пример #2
0
Файл: worker.py Проект: xbx/zato
    def init(self):
        plain_http_config = MultiDict()
        soap_config = MultiDict()
        
        dol = deepcopy(self.worker_config.http_soap).dict_of_lists()
        
        for url_path in dol:
            for item in dol[url_path]:
                for soap_action, channel_info in item.items():
                    if channel_info['connection'] == 'channel':
                        if channel_info.transport == 'plain_http':
                            config = plain_http_config.setdefault(url_path, Bunch())
                            config[soap_action] = deepcopy(channel_info)
                        else:
                            config = soap_config.setdefault(url_path, Bunch())
                            config[soap_action] = deepcopy(channel_info)
                
        self.request_dispatcher = RequestDispatcher(simple_io_config=self.worker_config.simple_io)
        self.request_dispatcher.soap_handler = SOAPHandler(soap_config, self.server)
        self.request_dispatcher.plain_http_handler = PlainHTTPHandler(plain_http_config, self.server)
        
        # Statistics maintenance
        self.stats_maint = MaintenanceTool(self.kvdb.conn)

        self.request_dispatcher.security = ConnectionHTTPSOAPSecurity(
            self.server.odb.get_url_security(self.server.cluster_id, 'channel')[0],
            self.worker_config.basic_auth, self.worker_config.tech_acc, self.worker_config.wss)
        
        # Create all the expected connections
        self.init_sql()
        self.init_ftp()
        self.init_http_soap()
Пример #3
0
def test_dict():
    d = MultiDict({'a': 1})
    assert d.items() == [('a', 1)]

    d['b'] = 2
    d['c'] = 3
    assert d.items() == [('a', 1), ('b', 2), ('c', 3)]

    d['b'] = 4
    assert d.items() == [('a', 1), ('c', 3), ('b', 4)]

    d.add('b', 5)
    raises(KeyError, 'd.getone("b")')
    assert d.getall('b') == [4, 5]
    assert d.items() == [('a', 1), ('c', 3), ('b', 4), ('b', 5)]

    del d['b']
    assert d.items() == [('a', 1), ('c', 3)]
    assert d.pop('xxx', 5) == 5
    assert d.getone('a') == 1
    assert d.popitem() == ('c', 3)
    assert d.items() == [('a', 1)]

    item = []
    assert d.setdefault('z', item) is item
    assert d.items() == [('a', 1), ('z', item)]

    assert d.setdefault('y', 6) == 6

    assert d.mixed() == {'a': 1, 'y': 6, 'z': item}
    assert d.dict_of_lists() == {'a': [1], 'y': [6], 'z': [item]}

    assert 'a' in d
    dcopy = d.copy()
    assert dcopy is not d
    assert dcopy == d
    d['x'] = 'x test'
    assert dcopy != d

    d[(1, None)] = (None, 1)
    assert d.items() == [('a', 1), ('z', []), ('y', 6), ('x', 'x test'),
                         ((1, None), (None, 1))]
Пример #4
0
def test_dict():
    d = MultiDict({'a': 1})
    assert list(d.items()) == [('a', 1)]

    d['b'] = 2
    d['c'] = 3
    assert list(d.items()) == [('a', 1), ('b', 2), ('c', 3)]

    d['b'] = 4
    assert list(d.items()) == [('a', 1), ('c', 3), ('b', 4)]

    d.add('b', 5)
    assert_raises(KeyError, d.getone, "b")
    assert d.getall('b') == [4, 5]
    assert list(d.items()) == [('a', 1), ('c', 3), ('b', 4), ('b', 5)]

    del d['b']
    assert list(d.items()) == [('a', 1), ('c', 3)]
    assert d.pop('xxx', 5) == 5
    assert d.getone('a') == 1
    assert d.popitem() == ('c', 3)
    assert list(d.items()) == [('a', 1)]

    item = []
    assert d.setdefault('z', item) is item
    assert list(d.items()) == [('a', 1), ('z', item)]

    assert d.setdefault('y', 6) == 6

    assert d.mixed() == {'a': 1, 'y': 6, 'z': item}
    assert d.dict_of_lists() == {'a': [1], 'y': [6], 'z': [item]}

    assert 'a' in d
    dcopy = d.copy()
    assert dcopy is not d
    assert dcopy == d
    d['x'] = 'x test'
    assert dcopy != d

    d[(1, None)] = (None, 1)
    assert list(d.items()) == [('a', 1), ('z', []), ('y', 6), ('x', 'x test'),
                         ((1, None), (None, 1))]