-
Notifications
You must be signed in to change notification settings - Fork 14k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aed473d
commit fc921d6
Showing
7 changed files
with
27 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,14 @@ | ||
from flask import flash | ||
|
||
|
||
class SourceRegistry(object): | ||
""" Central Registry for all available datasource engines""" | ||
|
||
sources = {} | ||
|
||
def add_source(self, ds_type, cls_model): | ||
if ds_type not in self.sources: | ||
self.sources[ds_type] = cls_model | ||
if self.sources[ds_type] is not cls_model: | ||
raise Exception( | ||
'source type: {} is already associated with Model: {}'.format( | ||
ds_type, self.sources[ds_type])) | ||
@classmethod | ||
def register_sources(cls, datasource_config): | ||
for module_name, class_names in datasource_config.items(): | ||
module_obj = __import__(module_name, fromlist=class_names) | ||
for class_name in class_names: | ||
source_class = getattr(module_obj, class_name) | ||
cls.sources[source_class.type] = source_class |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters