def setup_once(): # type: () -> None try: version = tuple(map(int, FLASK_VERSION.split(".")[:3])) except (ValueError, TypeError): raise DidNotEnable( "Unparseable Flask version: {}".format(FLASK_VERSION)) if version < (0, 11): raise DidNotEnable("Flask 0.11 or newer is required.") appcontext_pushed.connect(_push_appctx) appcontext_tearing_down.connect(_pop_appctx) request_started.connect(_request_started) got_request_exception.connect(_capture_exception) old_app = Flask.__call__ def sentry_patched_wsgi_app(self, environ, start_response): # type: (Any, Dict[str, str], Callable[..., Any]) -> _ScopedResponse if Hub.current.get_integration(FlaskIntegration) is None: return old_app(self, environ, start_response) return SentryWsgiMiddleware( lambda *a, **kw: old_app(self, *a, **kw))(environ, start_response) Flask.__call__ = sentry_patched_wsgi_app # type: ignore
def init_app(self, app): if self.__EXTENSION_NAME in app.extensions: log.warning('ActionRegistry.init_app: actions already enabled on this application') return app.extensions[self.__EXTENSION_NAME] = dict(categories=dict()) appcontext_pushed.connect(self._init_context, app) @app.context_processor def add_registry_to_jinja_context(): return dict(actions=self)
def init_app(self, app): """Initializes an app to work with this extension. The app-context signals will be subscribed and the template context will be initialized. :param app: the :class:`flask.Flask` app instance. """ # connects app-level signals appcontext_pushed.connect(self.initialize_bars, app) # integrate with jinja template app.add_template_global(self, 'nav')
def init_app(self, app: Flask) -> None: if self.__EXTENSION_NAME in app.extensions: log.warning( "ActionRegistry.init_app: actions already enabled on this application" ) return app.extensions[self.__EXTENSION_NAME] = {"categories": {}} appcontext_pushed.connect(self._init_context, app) @app.context_processor def add_registry_to_jinja_context() -> Dict[str, ActionRegistry]: return {"actions": self}
def install(self): appcontext_pushed.connect(_push_appctx) appcontext_tearing_down.connect(_pop_appctx) request_started.connect(_request_started) got_request_exception.connect(_capture_exception) old_app = Flask.__call__ def sentry_patched_wsgi_app(self, environ, start_response): return run_wsgi_app(lambda *a, **kw: old_app(self, *a, **kw), environ, start_response) Flask.__call__ = sentry_patched_wsgi_app
def init_app(self, app): if self.__EXTENSION_NAME in app.extensions: log.warning( "ActionRegistry.init_app: actions already enabled on this application" ) return app.extensions[self.__EXTENSION_NAME] = {"categories": {}} appcontext_pushed.connect(self._init_context, app) @app.context_processor def add_registry_to_jinja_context(): return {"actions": self}
def setup_once(): appcontext_pushed.connect(_push_appctx) appcontext_tearing_down.connect(_pop_appctx) request_started.connect(_request_started) got_request_exception.connect(_capture_exception) old_app = Flask.__call__ def sentry_patched_wsgi_app(self, environ, start_response): if Hub.current.get_integration(FlaskIntegration) is None: return old_app(self, environ, start_response) return run_wsgi_app(lambda *a, **kw: old_app(self, *a, **kw), environ, start_response) Flask.__call__ = sentry_patched_wsgi_app
def setup_once(): # type: () -> None appcontext_pushed.connect(_push_appctx) appcontext_tearing_down.connect(_pop_appctx) request_started.connect(_request_started) got_request_exception.connect(_capture_exception) old_app = Flask.__call__ def sentry_patched_wsgi_app(self, environ, start_response): # type: (Any, Dict[str, str], Callable[..., Any]) -> _ScopedResponse if Hub.current.get_integration(FlaskIntegration) is None: return old_app(self, environ, start_response) return SentryWsgiMiddleware( lambda *a, **kw: old_app(self, *a, **kw))(environ, start_response) Flask.__call__ = sentry_patched_wsgi_app # type: ignore
# -*- coding: utf-8 -*- from flask.signals import appcontext_pushed, signals_available from stackdriverlog.conf import load_settings def signal_handler(sender, **kwargs): """ Signals receiver for ``flask.appcontext_pushed`` signal. Get ``STACK_DRIVER_LOGGER`` namespace from flask app config, and reload the settings used to instantiate the ``StackDriverLogger`` class. """ user_settings = sender.config.get('LOGGING', None) load_settings(setting='LOGGING', value=user_settings) if signals_available: # If the ``blinker`` library is installed, # connect the signal to the signal handler. appcontext_pushed.connect(signal_handler)