From 1f0a85551042a8da5014f0ec05fec9110e583330 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Thu, 18 May 2017 16:31:43 +0200 Subject: [PATCH] Added pillar.current_app local proxy This proxy is annotated as PillarServer instance, so using it in an IDE will give you much better autocompletion. --- pillar/__init__.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pillar/__init__.py b/pillar/__init__.py index 426fdb21..17a4372e 100644 --- a/pillar/__init__.py +++ b/pillar/__init__.py @@ -19,6 +19,7 @@ from flask import render_template, request from flask.templating import TemplateNotFound import pymongo.collection import pymongo.database +from werkzeug.local import LocalProxy from pillar.api import custom_field_validation from pillar.api.utils import authentication @@ -616,3 +617,13 @@ class PillarServer(Eve): current_request.url_rule = rule yield ctx + + +def _get_current_app(): + """Returns the current application.""" + + return flask.current_app + + +current_app: PillarServer = LocalProxy(_get_current_app) +"""the current app, annotated as PillarServer"""