Repository navigation
refactor(widgets): split route templates and views by widget family (#121) - #133
Merged
manish-wekan merged 1 commit intoNov 9, 2026
Conversation
…itrocloudofficial#121) route_templates.py (870 lines) and views.py (569 lines) are now small route dispatchers. The per-widget code moved, unchanged, into: - views_common / views_pizza / views_flight: widget bodies - route_templates_generic / _pizza / _flight: CSS, render JS and page builders Dependencies run one way (views_common <- views_pizza, views_* <- views <- route_templates_* <- route_templates), with no import cycles. Every name the two old modules defined or imported is still importable from them, and the rendered HTML is byte-for-byte identical.
AadarshM07
approved these changes
Nov 9, 2026
AadarshM07
left a comment
Collaborator
There was a problem hiding this comment.
LGTM, Clean refactoring that meets the acceptance criteria. Splitting route templates and views by family keeps each module well below 500 lines while leaving compact dispatchers. All widget tests pass as well
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #121.
What changed
route_templates.py(870 lines) andviews.py(569 lines) are now small route dispatchers. The per-widget code moved, unchanged, into one module per widget family:views.pyBODY_BUILDERS+render_body(route → body dispatch), re-exportsviews_common.py_safe_int/_safe_float, generic, missing, calculator, card, table, chart bodiesviews_pizza.pyviews_flight.pyroute_templates.py_ROUTE_BUILDERS+render_widget_html/get_builtin_route_html/build_widget_html_for_route, re-exportsroute_templates_generic.py_pagewrapper, generic/missing/calculator/card/table/chart templatesroute_templates_pizza.pyroute_templates_flight.pyDependencies (one-directional, no cycles)
views_common←views_pizza;views_flightstands alone (both usehtml_util/ui)views_*←views(dispatch)views←route_templates_*(templates callrender_body, never a body module directly)route_templates_generic←route_templates_pizza/_flight(for_page)route_templatesEach module imports cleanly on its own in a fresh interpreter.
Behavior and imports preserved
render_widget_html,build_widget_html_for_routeandrender_bodyfor every route (plus unknown andwidget/...htmlroutes) with 7 data shapes, and forbuild_missing_widget/build_generic_widget: 338 cases. All 338 match after the split._safe_int,_safe_float,_ROUTE_BUILDERS).Not done, on purpose
The issue allows moving static HTML/JS into non-Python asset files. Every module is already under 500 lines without that, and keeping the strings in Python avoids any packaging change (
package_data) or output drift. Happy to do it as a follow-up if you prefer.Checks
developon my machine (test_oauth_clienton Python 3.14, code-mode / wheel-build template tests withoutsetuptools). CI runs 3.10 to 3.12.