From e67991c8ae1492ea475ac6ea07cd721f742d07c1 Mon Sep 17 00:00:00 2001 From: Eric Herrera Date: Tue, 7 Jul 2020 23:53:26 -0500 Subject: [PATCH 1/2] Add load function to avoid problems when serializing string resources form pkg_resources since it returns bytes object. --- recommender/recommender.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/recommender/recommender.py b/recommender/recommender.py index 15cf914..9cafff9 100644 --- a/recommender/recommender.py +++ b/recommender/recommender.py @@ -47,6 +47,10 @@ def emit(param1, param2): """ In workbench, do nothing for event emission """ pass +def load(path): + """Handy helper for getting resources from our kit.""" + data = pkg_resources.resource_string(__name__, path) + return data.decode("utf8") def stem_url(url): """ @@ -996,9 +1000,9 @@ def studio_view(self, _context=None): # pylint: disable=unused-argument self._init_template_lookup() frag = Fragment(template_lookup.get_template("recommenderstudio.html").render()) - frag.add_css(pkg_resources.resource_string(__name__, "static/css/recommenderstudio.css")) + frag.add_css(load("static/css/recommenderstudio.css")) frag.add_javascript_url("//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js") - frag.add_javascript(pkg_resources.resource_string(__name__, "static/js/src/recommenderstudio.js")) + frag.add_javascript(load("static/js/src/recommenderstudio.js")) frag.initialize_js('RecommenderXBlock') return frag From d2344e9433adf880097a8cc216be63b0492c2716 Mon Sep 17 00:00:00 2001 From: Eric Herrera Date: Thu, 9 Jul 2020 20:30:53 -0500 Subject: [PATCH 2/2] Fix tests. Bump version. --- recommender/recommender.py | 2 ++ setup.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/recommender/recommender.py b/recommender/recommender.py index 9cafff9..1876c7f 100644 --- a/recommender/recommender.py +++ b/recommender/recommender.py @@ -47,11 +47,13 @@ def emit(param1, param2): """ In workbench, do nothing for event emission """ pass + def load(path): """Handy helper for getting resources from our kit.""" data = pkg_resources.resource_string(__name__, path) return data.decode("utf8") + def stem_url(url): """ Get the base form of url. diff --git a/setup.py b/setup.py index 5785576..a15a4b6 100644 --- a/setup.py +++ b/setup.py @@ -47,7 +47,7 @@ def package_data(pkg, root_list): setup( name='recommender-xblock', - version='1.4.8', + version='1.4.9', description='recommender XBlock', # TODO: write a better description. long_description=README, author='edX',