pfalcon / utemplate

Micro template engine in Python with low memory usage, designed for Pycopy, a minimalist Python dialect, but also compatible with other Pythons.
https://github.com/pfalcon/pycopy
76 stars 8 forks source link

Trouble running the PicoWeb examples when using utemplate #9

Closed joewez closed 6 years ago

joewez commented 6 years ago

I have frozen PicoWeb (and uasyncio) into and ESP8266 firmware bin. Then I added utemplate, the templates directory with squares.tpl and example_webapp.py. On first run I get this...

` 33.000 <HTTPRequest object at 3fff36f0> <StreamWriter > "GET /squares"

33.000 <HTTPRequest object at 3fff36f0> <StreamWriter > AttributeError("'module' object has no attribute 'path'",) Traceback (most recent call last):

File "picoweb/init.py", line 188, in _handle

File "example_webapp.py", line 22, in squares

File "picoweb/init.py", line 231, in render_template

File "picoweb/init.py", line 227, in _load_template

File "utemplate/source.py", line 153, in init

AttributeError: 'module' object has no attribute 'path' `

If I add a path declaration to example_webapp.py I get this...

` 133.999 <HTTPRequest object at 3fff4c80> <StreamWriter > "GET /squares"

136.000 <HTTPRequest object at 3fff4c80> <StreamWriter > ImportError("no module named 'example_webapp.templates'",) Traceback (most recent call last):

File "picoweb/init.py", line 188, in _handle

File "example_webapp.py", line 24, in squares

File "picoweb/init.py", line 231, in render_template

File "picoweb/init.py", line 228, in _load_template

File "utemplate/source.py", line 182, in load

File "utemplate/compiled.py", line 14, in load

ImportError: no module named 'example_webapp.templates' `

Everything else works as expected so I think the problem is specifically with utemplate.

pfalcon commented 6 years ago

This seems to be duplicate of https://github.com/pfalcon/picoweb/issues/15 . The examples distributed with Picoweb are originally intended to run with Unix port, and apparently need tweaking for no-command-line environments.

If you want to see an example which guaranteedly runs on esp8266, it's https://github.com/pfalcon/notes-pico (follow its instructions!).