Как получить доступ к app.config из проекта вне запроса (Flask, подключаемые представления) - PullRequest
0 голосов
/ 05 марта 2020

Я хотел бы получить доступ к app.config из класса Pluggable View

Что у меня есть: flask приложение, подключаемые представления, чертежи

from flask import current_app

# using pluggable views
class Router(MethodView):

  # applying flask_login.login_required to all methods
  # in the current class
  decorators = [flask_login.login_required]   

  def get(self, *args, **kwargs):
    pass

  def post(self, *args, **kwargs):
    pass

Что я хочу : (это не работает, поскольку нет контекста приложения / запроса и не установлено current_app)

from flask import current_app


class Router(MethodView):

  # this does not work
  if current_app.config['LOGIN_REQUIRED']:       
    decorators = [flask_login.login_required]  

  def get(self, *args, **kwargs):
    pass

  def post(self, *args, **kwargs):
    pass
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...