- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / common / extensions / docs / server2 / data_source_registry.py
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
5 from data_source import DataSource
6 from manifest_data_source import ManifestDataSource
7 from permissions_data_source import PermissionsDataSource
8 from sidenav_data_source import SidenavDataSource
9 from strings_data_source import StringsDataSource
10 from template_data_source import TemplateDataSource
11
12
13 _all_data_sources = {
14   'manifest_source': ManifestDataSource,
15   'partials': TemplateDataSource,
16   'permissions': PermissionsDataSource,
17   'sidenavs': SidenavDataSource,
18   'strings': StringsDataSource,
19 }
20
21 assert all(issubclass(cls, DataSource)
22            for cls in _all_data_sources.itervalues())
23
24 def CreateDataSources(server_instance, request=None):
25   '''Create a dictionary of initialized DataSources. DataSources are
26   initialized with |server_instance| and |request|. If the DataSources are
27   going to be used for Cron, |request| should be omitted.
28
29   The key of each DataSource is the name the template system will use to access
30   the DataSource.
31   '''
32   return dict((name, cls(server_instance, request))
33               for name, cls in _all_data_sources.iteritems())