forked from openedx/edx-platform
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request openedx#1122 from proversity-org/ir/pearson/PE-785
PE-785 - Adding custom course home feature
- Loading branch information
Showing
3 changed files
with
67 additions
and
0 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
46 changes: 46 additions & 0 deletions
46
openedx/core/djangoapps/plugins/plugin_extension_points.py
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
""" | ||
Plugin extension points module | ||
""" | ||
import logging | ||
from importlib import import_module | ||
|
||
from django.conf import settings | ||
|
||
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
|
||
def run_extension_point(extension_point, *args, **kwargs): | ||
""" | ||
Wrapper function to execute any extension point at platform level | ||
if exceptions occurs returns None. | ||
""" | ||
path = None | ||
|
||
try: | ||
path = configuration_helpers.get_value( | ||
extension_point, | ||
getattr(settings, extension_point, None), | ||
) | ||
|
||
if not path: | ||
return None | ||
except AttributeError: | ||
return None | ||
|
||
try: | ||
module_name, func_name = path.rsplit('.', 1) | ||
module = import_module(module_name) | ||
extension_function = getattr(module, func_name) | ||
|
||
return extension_function(*args, **kwargs) | ||
except ImportError: | ||
log.info('Could not import the %s : %s', extension_point, module) | ||
return None | ||
except AttributeError: | ||
log.info('Could not import the function %s in the module %s', func_name, module) | ||
return None | ||
except ValueError: | ||
log.info('Could not load the information from \"%s\"', path) | ||
return None |
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