data_source_registry.py revision effb81e5f8246d0db0270817048dc992db66e9fb
1# Copyright 2013 The Chromium Authors. All rights reserved. 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5from api_list_data_source import APIListDataSource 6from data_source import DataSource 7from manifest_data_source import ManifestDataSource 8from permissions_data_source import PermissionsDataSource 9from sidenav_data_source import SidenavDataSource 10from strings_data_source import StringsDataSource 11from template_data_source import ( 12 ArticleDataSource, IntroDataSource, PartialDataSource) 13from whats_new_data_source import WhatsNewDataSource 14 15 16_all_data_sources = { 17 'api_list': APIListDataSource, 18 'articles': ArticleDataSource, 19 'intros': IntroDataSource, 20 'manifest_source': ManifestDataSource, 21 'partials': PartialDataSource, 22 'permissions': PermissionsDataSource, 23 'sidenavs': SidenavDataSource, 24 'strings': StringsDataSource, 25 'whatsNew' : WhatsNewDataSource 26} 27 28assert all(issubclass(cls, DataSource) 29 for cls in _all_data_sources.itervalues()) 30 31def CreateDataSources(server_instance, request=None): 32 '''Create a dictionary of initialized DataSources. DataSources are 33 initialized with |server_instance| and |request|. If the DataSources are 34 going to be used for Cron, |request| should be omitted. 35 36 The key of each DataSource is the name the template system will use to access 37 the DataSource. 38 ''' 39 return dict((name, cls(server_instance, request)) 40 for name, cls in _all_data_sources.iteritems()) 41