UCL-INGI / ICTV

ICTV is a simple content management system for digital signage on multiple screens.
Other
15 stars 5 forks source link

Transition to Jinja2 #29

Closed l9kd1 closed 3 years ago

l9kd1 commented 3 years ago

Switching the template engine with Jinja2.

l9kd1 commented 3 years ago

Understood. I'll be squashing commits from now on.

anthonygego commented 3 years ago

Got this on the /loginpage:

Traceback (most recent call last):
  File "/home/anthony/Documents/ICTV/venv/lib64/python3.6/site-packages/web/application.py", line 257, in process
    return self.handle()
  File "/home/anthony/Documents/ICTV/venv/lib64/python3.6/site-packages/web/application.py", line 248, in handle
    return self._delegate(fn, self.fvars, args)
  File "/home/anthony/Documents/ICTV/venv/lib64/python3.6/site-packages/web/application.py", line 488, in _delegate
    return handle_class(cls)
  File "/home/anthony/Documents/ICTV/venv/lib64/python3.6/site-packages/web/application.py", line 466, in handle_class
    return tocall(*args)
  File "/home/anthony/Documents/ICTV/ictv/pages/local_login.py", line 39, in GET
    return self.render_page()
  File "/home/anthony/Documents/ICTV/ictv/pages/local_login.py", line 57, in render_page
    return self.standalone_renderer.login(self.config['authentication'], self.config['saml2']['display_name'])
  File "/home/anthony/Documents/ICTV/venv/lib64/python3.6/site-packages/jinja2/environment.py", line 1299, in render
    ctx = self.new_context(dict(*args, **kwargs))
TypeError: dict expected at most 1 arguments, got 2

127.0.0.1:46764 - - [20/Jul/2021 10:21:51] "HTTP/1.1 GET /login" - 500 Internal Server Error
l9kd1 commented 3 years ago

The login page should work now.

Drumor commented 3 years ago

Have an error visiting /channel/id_of_channel :

Traceback (most recent call last): File "/usr/local/lib/python3.5/dist-packages/web/application.py", line 257, in process return self.handle() File "/usr/local/lib/python3.5/dist-packages/web/application.py", line 248, in handle return self._delegate(fn, self.fvars, args) File "/usr/local/lib/python3.5/dist-packages/web/application.py", line 488, in _delegate return handle_class(cls) File "/usr/local/lib/python3.5/dist-packages/web/application.py", line 466, in handle_class return tocall(args) File "/home/ludovic/Documents/Repository/ictv/ictv/pages/channel_page.py", line 52, in GET return self.render_page(channel) File "/home/ludovic/Documents/Repository/ictv/ictv/app.py", line 150, in decorated_function return f(args, **kwargs) File "/home/ludovic/Documents/Repository/ictv/ictv/pages/channel_page.py", line 93, in render_page return self.renderer.channeld(channel=channel, channel_type=type(channel).name, current_user=current_user, File "/usr/local/lib/python3.5/dist-packages/web/contrib/template.py", line 95, in getattr t = self._lookup.get_template(path) File "/usr/local/lib/python3.5/dist-packages/jinja2/environment.py", line 830, in get_template return self._load_template(name, self.make_globals(globals)) File "/usr/local/lib/python3.5/dist-packages/jinja2/environment.py", line 804, in _load_template template = self.loader.load(self, name, globals) File "/usr/local/lib/python3.5/dist-packages/jinja2/loaders.py", line 125, in load code = environment.compile(source, name, filename) File "/usr/local/lib/python3.5/dist-packages/jinja2/environment.py", line 591, in compile self.handle_exception(exc_info, source_hint=source_hint) File "/usr/local/lib/python3.5/dist-packages/jinja2/environment.py", line 780, in handle_exception reraise(exc_type, exc_value, tb) File "/usr/local/lib/python3.5/dist-packages/jinja2/_compat.py", line 37, in reraise raise value.with_traceback(tb) File "/home/ludovic/Documents/Repository/ictv/ictv/templates/channeld.html", line 127, in template

{{sub.fullname if sub.fullname is not None else sub.username}}

File "/usr/local/lib/python3.5/dist-packages/jinja2/environment.py", line 543, in _generate optimized=self.optimized) File "/usr/local/lib/python3.5/dist-packages/jinja2/compiler.py", line 82, in generate generator.visit(node) File "/usr/local/lib/python3.5/dist-packages/jinja2/visitor.py", line 38, in visit return f(node, *args, kwargs) File "/usr/local/lib/python3.5/dist-packages/jinja2/compiler.py", line 799, in visit_Template self.blockvisit(block.body, block_frame) File "/usr/local/lib/python3.5/dist-packages/jinja2/compiler.py", line 378, in blockvisit self.visit(node, frame) File "/usr/local/lib/python3.5/dist-packages/jinja2/visitor.py", line 38, in visit return f(node, *args, *kwargs) File "/usr/local/lib/python3.5/dist-packages/jinja2/compiler.py", line 1160, in visit_If self.blockvisit(node.body, if_frame) File "/usr/local/lib/python3.5/dist-packages/jinja2/compiler.py", line 378, in blockvisit self.visit(node, frame) File "/usr/local/lib/python3.5/dist-packages/jinja2/visitor.py", line 38, in visit return f(node, args, kwargs) File "/usr/local/lib/python3.5/dist-packages/jinja2/compiler.py", line 1160, in visit_If self.blockvisit(node.body, if_frame) File "/usr/local/lib/python3.5/dist-packages/jinja2/compiler.py", line 378, in blockvisit self.visit(node, frame) File "/usr/local/lib/python3.5/dist-packages/jinja2/visitor.py", line 38, in visit return f(node, *args, kwargs) File "/usr/local/lib/python3.5/dist-packages/jinja2/compiler.py", line 1122, in visit_For self.blockvisit(node.body, loop_frame) File "/usr/local/lib/python3.5/dist-packages/jinja2/compiler.py", line 378, in blockvisit self.visit(node, frame) File "/usr/local/lib/python3.5/dist-packages/jinja2/visitor.py", line 38, in visit return f(node, *args, *kwargs) File "/usr/local/lib/python3.5/dist-packages/jinja2/compiler.py", line 1358, in visit_Output self.visit(argument, frame) File "/usr/local/lib/python3.5/dist-packages/jinja2/visitor.py", line 38, in visit return f(node, args, kwargs) File "/usr/local/lib/python3.5/dist-packages/jinja2/compiler.py", line 70, in new_func return f(self, node, frame, kwargs) File "/usr/local/lib/python3.5/dist-packages/jinja2/compiler.py", line 1624, in visit_CondExpr self.visit(node.test, frame) File "/usr/local/lib/python3.5/dist-packages/jinja2/visitor.py", line 38, in visit return f(node, args, kwargs) File "/usr/local/lib/python3.5/dist-packages/jinja2/compiler.py", line 70, in new_func return f(self, node, frame, kwargs) File "/usr/local/lib/python3.5/dist-packages/jinja2/compiler.py", line 1497, in visitor self.visit(node.node, frame) File "/usr/local/lib/python3.5/dist-packages/jinja2/visitor.py", line 38, in visit return f(node, args, kwargs) File "/usr/local/lib/python3.5/dist-packages/jinja2/compiler.py", line 70, in new_func return f(self, node, frame, **kwargs) File "/usr/local/lib/python3.5/dist-packages/jinja2/compiler.py", line 1607, in visit_Test self.fail('no test named %r' % node.name, node.lineno) File "/usr/local/lib/python3.5/dist-packages/jinja2/compiler.py", line 315, in fail raise TemplateAssertionError(msg, lineno, self.name, self.filename) jinja2.exceptions.TemplateAssertionError: no test named 'None'

127.0.0.1:54104 - - [22/Jul/2021 15:14:06] "HTTP/1.1 GET /channel/1" - 500 Internal Server Error

l9kd1 commented 3 years ago

Have an error visiting /channel/id_of_channel :

Could not reproduce the error locally but the latest commit should do the trick. Does it work now ?

Drumor commented 3 years ago

Fixed.

Have now "KeyError" on preview of channel:

Traceback (most recent call last): File "/usr/local/lib/python3.5/dist-packages/web/application.py", line 257, in process return self.handle() File "/usr/local/lib/python3.5/dist-packages/web/application.py", line 248, in handle return self._delegate(fn, self.fvars, args) File "/usr/local/lib/python3.5/dist-packages/web/application.py", line 488, in _delegate return handle_class(cls) File "/usr/local/lib/python3.5/dist-packages/web/application.py", line 466, in handle_class return tocall(*args) File "/home/ludovic/Documents/Repository/ictv/ictv/pages/channel_renderer.py", line 47, in GET return self.ictv_renderer.preview_capsules(channel_capsules, context='channel', auto_slide=True) File "/home/ludovic/Documents/Repository/ictv/ictv/renderer/renderer.py", line 139, in preview_capsules content, themes = self.render_capsules(capsules, context) File "/home/ludovic/Documents/Repository/ictv/ictv/renderer/renderer.py", line 108, in render_capsules content += self.render_capsule(capsule=capsule) File "/home/ludovic/Documents/Repository/ictv/ictv/renderer/renderer.py", line 89, in render_capsule slide_defaults = Themes.get_slide_defaults(capsule_theme) File "/home/ludovic/Documents/Repository/ictv/ictv/renderer/renderer.py", line 365, in get_slide_defaults parent = cls[theme].get('parent') File "/home/ludovic/Documents/Repository/ictv/ictv/renderer/renderer.py", line 310, in getitem return self._themes[item] KeyError: 'ucl'

l9kd1 commented 3 years ago

Couldn't recreate this locally, I might need the procedure to apply in order to add a new theme and how/where to select it in the "editor".

This might also be caused by an old version of the plugin repo and/or the absence of an "ucl" directory in the renderer/theme folder.

Dj0ulo commented 3 years ago

Couldn't recreate this locally, I might need the procedure to apply in order to add a new theme and how/where to select it in the "editor".

This might also be caused by an old version of the plugin repo and/or the absence of an "ucl" directory in the renderer/theme folder.

I managed to recreate the error by creating a slide with the UCL theme and by deleting the folder renderer/themes/ucl after that. This folder is in the ICTV-UCL repo on forge. So the error comes from the fact that you had a slide with ucl theme in your database but not your themes folder. And it is the same error in the original repo with web.py

anthonygego commented 3 years ago

LGTM. I'll squash all the commits.