Saving page in admin GUI sets template to empty
See original GitHub issueI think this bug only exists on master (no release yet). I’m creating this issue to ensure that we don’t release a new version until it’s fixed. Alternatively we have to establish that the cause is not something else on my system 😅
I installed Lektor like this (probably not related):
# Install lektor
pip3 install --user git+https://github.com/lektor/lektor
# Generate JS files for admin
cd ~/.local/lib/python3.7/site-packages/lektor/admin/
npm install
npm run webpack
# Create a new project and start admin GUI
lektor quickstart
cd <your-project>
lektor server
Open the admin GUI and edit the home page and click save (no need to make any changes).
You should see the following error:
Traceback (most recent call last):
File "/home/$USER/.local/lib/python3.7/site-packages/lektor/builder.py", line 800, in update
yield ctx
File "/home/$USER/.local/lib/python3.7/site-packages/lektor/builder.py", line 1070, in build_artifact
build_func(artifact)
File "/home/$USER/.local/lib/python3.7/site-packages/lektor/build_programs.py", line 183, in build_artifact
self.source['_template'], this=self.source)
File "/home/$USER/.local/lib/python3.7/site-packages/lektor/builder.py", line 655, in render_template_into
this=this, **extra)
File "/home/$USER/.local/lib/python3.7/site-packages/lektor/environment.py", line 542, in render_template
return self.jinja_env.get_or_select_template(name).render(ctx)
File "/usr/lib/python3.7/site-packages/jinja2/environment.py", line 869, in get_or_select_template
return self.get_template(template_name_or_list, parent, globals)
File "/usr/lib/python3.7/site-packages/jinja2/environment.py", line 830, in get_template
return self._load_template(name, self.make_globals(globals))
File "/home/$USER/.local/lib/python3.7/site-packages/lektor/environment.py", line 217, in _load_template
rv = jinja2.Environment._load_template(self, name, globals)
File "/usr/lib/python3.7/site-packages/jinja2/environment.py", line 804, in _load_template
template = self.loader.load(self, name, globals)
File "/usr/lib/python3.7/site-packages/jinja2/loaders.py", line 113, in load
source, filename, uptodate = self.get_source(environment, name)
File "/usr/lib/python3.7/site-packages/jinja2/loaders.py", line 187, in get_source
raise TemplateNotFound(template)
jinja2.exceptions.TemplateNotFound
If I look into the contents.lr
file I can see that Lektor has saved some system fields and set their values to empty:
title: Welcome to asdf!
---
body:
This is a basic demo website that shows how to use Lektor for a basic
website with some pages and a blog.
---
_discoverable:
---
_hidden:
---
_slug:
---
_template:
In previous versions Lektor has never saved these fields (_discoverable
, _hidden
, _slug
and _template
) unless they have an explicitly defined value. I suspect this is caused by one of the PRs related to admin form handling: #660, #667, #670 or #679. I’ll try to bisect this issue later.
Environment
- Python 3.7
- Firefox 69
- Fedora 30
- npm 6.9.0
- node js 10.16.3
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (5 by maintainers)
Top GitHub Comments
Sure, that will probably fix it. I think we might even be able to go as far as filtering out all empty fields.
However, I’d like to find out how and why this happened first before fixing it this way though.
I managed to bisect this to the commit 11e94e1720f1cad1844967ccdd77b92b11839527. I’ll open a PR reverting that commit but will try to port the performance optimization.