Skip to first unread message


Jun 2, 2021, 1:57:58 AM6/2/21
to py4web

There is a PR outstanding about replacing yatl with Renoir which is faster and backward compatible.

One issue that I am unsure about is what to do with the yatl.helpers. The PR moves them into py4web.utils.helpers. That is ok as fast as py4web is concerned but I have occasionally used them in other apps, without py4web. So there are multiple options:

1) duplicate the helpers in yatl and py4web and py4web no longer depends on yatl
2) py4web depends on yatl, helpers stay in yatl, yatl uses Renoir
3) py4web depends on both yatl (for helpers) and Renoir (for templates)


Kevin Keller

Jun 2, 2021, 5:23:44 AM6/2/21
to Massimo, py4web
I think 3) is fine. 

The benefits are that we dont need to update all the py4web components now that depend on yatl helpers the way they are imported now and take advantage of renoir for rendering. 
So all the benefits, none of the work.
Plus for now I like to think that if we replicate yatl helpers in py4web, we need to maintain them there and in yatl potentially.
I dont think its such a big deal to have py4webs "productivity tools" such as form, grid, auth depend on yatl. Py4web core is independent of yatl anyway as far as I understand. 
In any case, decouple py4web from yatl looks good on the surface, but in reality I dont think anyone is going to start using Jinja with Py4web anyday now. 
Nor is the community currently using it as a pure API framework currently. In fact we still use a lot of HTML rendering. 
So I dont think getting rid of yatl will extend the community to other developers (such as Jinja users) nor do I think it will provide tangible benefits to the community at the moment. 

Habing YATL using Renoir seems to have the potential to keep the communities apart.  While the idea is to come togehter. 

Thus I think Py4web using yatl.helpers for the helpers and renoir for rendering seems to be a great solution in my pov. 

We can still move the yatl helpers into py4web down the line as well in any case.

But if you ask me what is best right now, I think 3 it is. 

You received this message because you are subscribed to the Google Groups "py4web" group.
To unsubscribe from this group and stop receiving emails from it, send an email to py4web+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/py4web/b18e2453-cd28-4a86-9035-5b218eabe0a9n%40googlegroups.com.

Jim Steil

Jun 2, 2021, 9:59:43 AM6/2/21
to py4web
My initial reaction is to go with #2.  If yatl and renoir use the same implementation, then take advantage of the speed of renoir.

Does it make sense to ask the renoir maintainer to add the yatl helpers to renoir?


Kevin Keller

Jun 2, 2021, 10:24:31 AM6/2/21
to Jim Steil, py4web
Why do you prefer 2?

I understand it seems simpler but I was afraid that Renoir contributors will unlikely contribute to yatl just because it uses Renoir. It would be up to use to track Renoir changes and improvments and carry them over to yatl.

Or maybe I am wrong?

If I am then number 2 is fine for me as well. 

As for the yatl helpers I don't think Giovanni will introduce them to Renoir, but im happy to ask him.


Jun 3, 2021, 12:52:51 AM6/3/21
to py4web
My plan is to go with #3 then modify yatl to use renoir as an option. #3 is the least disruptive option and Luca has expressed valid concerns.

Luca de Alfaro

Jun 3, 2021, 1:04:32 AM6/3/21
to Massimo, py4web
Well I don't want to hold back a change for the better.  Maybe I can ask for a tiny bit of community help in patching all the repos used to teach py4web ... I also feel this is a situation that will recur: changes in py4web asking for changes in the apps. It might be worth thinking of how to facilitate that (a kind of app updater of some kind... not sure). 


Massimo DiPierro

Jun 3, 2021, 1:19:47 AM6/3/21
to Luca de Alfaro, py4web
The current plan will not require any app patching. Of course i could be mistaken but renoir is a superset of the yatl template and if yatl remains a requirement imports will not break.

Jacinto Parga

Sep 3, 2021, 7:52:00 AM9/3/21
to py4web
Hi, I have found a tiny issue with renoir.

I work with a Visual Studio formatter for html. I saves this code like:

<div class="card-content">
[[if tablename:]] [[=grid.render()]] [[else:]] [[for table in
tabledetails:]] [[if table._plural:]] [[=A(table._plural,
_href=URL('admin/'+table._tablename))]]<br />
[[else:]] [[=A(table._tablename,
_href=URL('admin/'+table._tablename))]]<br />
[[pass]] [[pass]] [[pass]]
<!-- /.d-flex -->

This error appears:

SyntaxError: invalid syntax

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/jacinto/.pyenv/versions/py4web382/lib/python3.8/site-packages/py4web/core.py", line 913, in wrapper
    ret = func(*func_args, **func_kwargs)
  File "/home/jacinto/.pyenv/versions/py4web382/lib/python3.8/site-packages/py4web/core.py", line 866, in wrapper
    ret = obj.transform(ret, shared_data)
  File "/home/jacinto/.pyenv/versions/py4web382/lib/python3.8/site-packages/py4web/core.py", line 572, in transform
    output = render(
  File "/home/jacinto/.pyenv/versions/py4web382/lib/python3.8/site-packages/py4web/core.py", line 543, in render
    return engine.render(filename, context=context)
  File "/home/jacinto/.pyenv/versions/py4web382/lib/python3.8/site-packages/renoir/apis.py", line 215, in render
    return self._render(source, file_path, context)
  File "/home/jacinto/.pyenv/versions/py4web382/lib/python3.8/site-packages/renoir/apis.py", line 193, in _render
  File "/home/jacinto/.pyenv/versions/py4web382/lib/python3.8/site-packages/renoir/debug.py", line 116, in make_traceback
    reraise(exc_type, exc_value, tb)
  File "/home/jacinto/.pyenv/versions/py4web382/lib/python3.8/site-packages/renoir/_internal.py", line 15, in reraise
    raise value.with_traceback(tb)
  File "/home/jacinto/xxxxxxxxxxxxx/xxxxxxxxxxx/xxxx/apps/_default/templates/gestion.html", line 26, in template
    [[if tablename:]] [[=grid.render()]] [[else:]] [[for table in
renoir.errors.TemplateSyntaxError: invalid syntax

ERROR:tornado.access:500 GET /administrador ( 276.55ms

The simple solution is saving it this way:

<div class="card-content">
  [[if tablename:]] [[=grid.render()]] [[else:]] [[for table in tabledetails:]] 
  [[if table._plural:]] [[=A(table._plural, _href=URL('admin/'+table._tablename))]]<br />
  [[else:]] [[=A(table._tablename, _href=URL('admin/'+table._tablename))]]<br />
  [[pass]] [[pass]] [[pass]]
  <!-- /.d-flex -->

Any idea to prevent this kind of errors?


Sep 6, 2021, 3:40:20 AM9/6/21
to py4web
Discuss with Giovanni and we agree this is not  Renoir issue.

[[for table in

Contains a newline and this is invalid. The code in between [[ .... ]] must be valid python code and this is not.
Maybe we could report a better error. Maybe open a ticket about that if you think that is the case.
Thanks for reporting this problem anyway.


Jacinto Parga

Sep 6, 2021, 3:38:48 PM9/6/21
to py4web
Yes, I agree, it was my fault due to the Prettier configuration. Prettier is a Visual Code extension that formats hmtl and javascript. The configuration cut the line of code between [[ ]] on character 80. That was my mistake.


Reply all
Reply to author
0 new messages