comparison piecrust/data/providersdata.py @ 1163:ed308313bcda

data: Allow combining different data providers.
author Ludovic Chabant <ludovic@chabant.com>
date Tue, 01 Oct 2019 07:35:50 -0700
parents 45ad976712ec
children
comparison
equal deleted inserted replaced
1162:c5c98d0fb4ec 1163:ed308313bcda
46 46
47 if existing is None: 47 if existing is None:
48 provider = build_data_provider(pname, source, self._page) 48 provider = build_data_provider(pname, source, self._page)
49 endpoint[endpoint_bits[-1]] = provider 49 endpoint[endpoint_bits[-1]] = provider
50 elif isinstance(existing, DataProvider): 50 elif isinstance(existing, DataProvider):
51 existing_source = existing._sources[0]
52 if (existing.PROVIDER_NAME != pname or
53 existing_source.SOURCE_NAME != source.SOURCE_NAME):
54 raise ConfigurationError(
55 "Can't combine data providers '%s' and '%' "
56 "(using sources '%s' and '%s') "
57 "on endpoint '%s'." %
58 (existing.PROVIDER_NAME, pname,
59 existing_source.SOURCE_NAME, source.SOURCE_NAME,
60 pendpoint))
61 existing._addSource(source) 51 existing._addSource(source)
62 else: 52 else:
63 raise ConfigurationError( 53 raise ConfigurationError(
64 "Endpoint '%s' can't be used for a data provider because " 54 "Endpoint '%s' can't be used for a data provider because "
65 "it's already used for something else." % pendpoint) 55 "it's already used for something else." % pendpoint)