You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am working on building software product lines for Flask applications and I am trying to use an aspect to make Flask's render_template function render from another HTML file:
from flask import render_template, Blueprint, url_for, redirect, request
from flask.views import MethodView
...
from aspectlib import Aspect, Proceed, weave
...
bp = Blueprint('home', __name__, template_folder='../templates')
class MessageForm(Form):
...
@Aspect
def render_author(*args, **kwargs):
print("Rendering page with author information...")
yield Proceed('homeWithAuthor.html', **kwargs)
class HomeView(MethodView):
def get(self):
with weave(render_template, render_author):
form = MessageForm(request.form)
messages = db.session.execute(db.select(Message)).scalars()
return render_template(
"home.html",
form=form,
messages=messages
)
def post(self):
...
bp.add_url_rule("/", view_func=HomeView.as_view("home"))
The app would render from the original file instead of the stated file in the aspect though. There were no errors in weaving and running the app. Upon inspection with a debugger, the aspect has not been called at all. I have tried other arguments in the weaver including
and they all have the same result. The weaver works with builtin functions and class methods so I think it is an issue of me not weaving the aspect correctly.
Any help is appreciated, thanks!
The text was updated successfully, but these errors were encountered:
I am working on building software product lines for Flask applications and I am trying to use an aspect to make Flask's render_template function render from another HTML file:
The app would render from the original file instead of the stated file in the aspect though. There were no errors in weaving and running the app. Upon inspection with a debugger, the aspect has not been called at all. I have tried other arguments in the weaver including
and they all have the same result. The weaver works with builtin functions and class methods so I think it is an issue of me not weaving the aspect correctly.
Any help is appreciated, thanks!
The text was updated successfully, but these errors were encountered: