[GH-ISSUE #365] restructure templates so a 404 doesn't access the DB #279

Closed
opened 2026-02-26 10:30:29 +03:00 by kerem · 4 comments
Owner

Originally created by @ThomasWaldmann on GitHub (Sep 30, 2018).
Original GitHub issue: https://github.com/nsupdate-info/nsupdate.info/issues/365

Originally assigned to: @ThomasWaldmann on GitHub.

In nsupdate.context_processors.update_ips, it calls requestion.session.save() causing a DB write - even if we just want to render a 404 page.

This should be way less heavy.

Originally created by @ThomasWaldmann on GitHub (Sep 30, 2018). Original GitHub issue: https://github.com/nsupdate-info/nsupdate.info/issues/365 Originally assigned to: @ThomasWaldmann on GitHub. In `nsupdate.context_processors.update_ips`, it calls `requestion.session.save()` causing a DB write - even if we just want to render a 404 page. This should be way less heavy.
kerem closed this issue 2026-02-26 10:30:29 +03:00
Author
Owner

@ThomasWaldmann commented on GitHub (Sep 30, 2018):

see #356 for an example.

<!-- gh-comment-id:425755203 --> @ThomasWaldmann commented on GitHub (Sep 30, 2018): see #356 for an example.
Author
Owner

@ThomasWaldmann commented on GitHub (Oct 1, 2018):

see #367 for a workaround.

is there a way to know (in a context processor) for which template the context is being prepared?
then we could return early/empty if we know it is just an error template and not even try to save the session.

@elnappo ^

<!-- gh-comment-id:425902783 --> @ThomasWaldmann commented on GitHub (Oct 1, 2018): see #367 for a workaround. is there a way to know (in a context processor) for which template the context is being prepared? then we could return early/empty if we know it is just an error template and not even try to save the session. @elnappo ^
Author
Owner

@ThomasWaldmann commented on GitHub (Oct 16, 2018):

I couldn't find a way for the context_processor to see for which template it is being used.

What we do have though is request.method and request.path_info.

Also, the context processors are ONLY invoked if a template is in fact rendered.
So our stuff at /nic/... won't invoke them because it does not use templates.

<!-- gh-comment-id:430253415 --> @ThomasWaldmann commented on GitHub (Oct 16, 2018): I couldn't find a way for the context_processor to see for which template it is being used. What we do have though is `request.method` and `request.path_info`. Also, the context processors are ONLY invoked if a template is in fact rendered. So our stuff at `/nic/...` won't invoke them because it does not use templates.
Author
Owner

@ThomasWaldmann commented on GitHub (Oct 18, 2018):

i hopefully worked around the problem by using the file-based session store, so the session saves won't hammer the db.

for the error pages, i guess there is only one solution: not using templates, so the context processors won't get executed. note: even the default error pages use in-code templates, so they need to get overridden.

<!-- gh-comment-id:431174747 --> @ThomasWaldmann commented on GitHub (Oct 18, 2018): i hopefully worked around the problem by using the file-based session store, so the session saves won't hammer the db. for the error pages, i guess there is only one solution: not using templates, so the context processors won't get executed. note: even the default error pages use in-code templates, so they need to get overridden.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/nsupdate.info-nsupdate-info#279
No description provided.