Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

Allow render_template to be overwritten #179

Closed
rochacbruno opened this issue Nov 7, 2013 · 0 comments
Closed

Allow render_template to be overwritten #179

rochacbruno opened this issue Nov 7, 2013 · 0 comments

Comments

@rochacbruno
Copy link
Contributor

HI,

I am using a Flask-Themes application https://github.com/pythonhub/quokka-themes

I can customize the theme for almost all apps, even for Flask-Admin I can do it by extending the main class

from flask.ext.admin import Admin

class MyCustomAdmin(Admin):
    def render_template(self, *args, **kwargs):
        # here I load my theme template

But I was trying to do the same with Security

from flask.ext.security import Security

class MyCustomSecurity(Security):
    def render_template(self, *args, **kwargs):
        # here I load my theme template

But I figured out that Security main class does not expose a render method to be ovewritten.

It is now being done directly by the views, so I suggest to have a method and use this for rendering templates, or maybe have a config variable.

SECURITY_RENDER = 'somewhere.module:render_template'

So with the above setting you can do in views.py

from werkzeug.utils import import_string
render_template = import_string(config.get('SECURITY_RENDER'))

Having its default to a normal render_template from Flask.

But I prefer the first case when the class expose a render method to be overwritten.

By now I will create a fork and implement that for my specific case.. If I got some idea I will send a PR.

What do you thing about it? @mattupstate

rochacbruno added a commit to quokkaproject/quokka that referenced this issue Nov 7, 2013
installing security from pythonhub repo while not merged or found another
solution
mattupstate pushed a commit that referenced this issue Jan 24, 2014
Allow overwritten on render_template to use Flask-Themes based app #179
galeo pushed a commit to galeo/flask-security-outdated that referenced this issue Mar 4, 2020
is_json() just looks at Content-Type - which in 90% of cases is fine - but in some
cases (and to be more spec-compliant) we should really be honoring the Accept header.
This adds that into all our view responses.
kalkehcoisa pushed a commit to kalkehcoisa/quokka that referenced this issue Jan 30, 2024
installing security from pythonhub repo while not merged or found another
solution
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants