miguelgrinberg / turbo-flask

Integration of Hotwire's Turbo library with Flask.
MIT License
301 stars 35 forks source link

Turbo not working with Blueprints #16

Closed BestITUserEUW closed 2 years ago

BestITUserEUW commented 2 years ago

I have an Issue when trying to use Turbo Flask with Blueprints. It displays the Data only when refreshing the Page and just ones for the Sleep time between Rendering. Followed your Answer on the Issue https://issueexplorer.com/issue/miguelgrinberg/turbo-flask/7 but that didnt helped either. Link to my Code: https://github.com/BestITUserEUW/turboflask.git

miguelgrinberg commented 2 years ago

Not sure this is the only problem, but you are using a Blueprint-specific context processor to install the load variables in the Jinja context. That means that only routes from this blueprint will see those. You are calling render_template() in a background thread, which has no concept of blueprints, so those will not be accessible there. You should use an app-wide context processor for your load variables if you intend to use them outside of the blueprint.

BestITUserEUW commented 2 years ago

Thank you for your fast reply. Made it to Work with changing: @main.context_processor to @main.app_context_processor I have another Question can i stop the thread when changing the template to another one ?

miguelgrinberg commented 2 years ago

You can, but this is completely unrelated to this extension. You will have to build a mechanism to signal the thread to end.

BestITUserEUW commented 2 years ago

Ok thank you again for your help