From 86b4b141125828cd45963d041ab59dfe4c2cc1d2 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Mon, 20 May 2024 01:54:25 +0200 Subject: [PATCH] Added the current running application as a static object. ```python from platypush import app ``` --- platypush/__init__.py | 3 ++- platypush/app/__init__.py | 4 ++-- platypush/app/_app.py | 5 +++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/platypush/__init__.py b/platypush/__init__.py index 0d569d8d1..8fd3c81a9 100644 --- a/platypush/__init__.py +++ b/platypush/__init__.py @@ -5,7 +5,7 @@ Platypush .. license: MIT """ -from .app import Application +from .app import Application, app from .config import Config from .context import Variable, get_backend, get_bus, get_plugin from .cron import cron @@ -31,6 +31,7 @@ __all__ = [ 'Event', 'Request', 'Response', + 'app', 'cron', 'get_backend', 'get_bus', diff --git a/platypush/app/__init__.py b/platypush/app/__init__.py index 4bd528318..f08bd5cb7 100644 --- a/platypush/app/__init__.py +++ b/platypush/app/__init__.py @@ -1,4 +1,4 @@ -from ._app import Application, main +from ._app import Application, app, main -__all__ = ["Application", "main"] +__all__ = ["Application", "app", "main"] diff --git a/platypush/app/_app.py b/platypush/app/_app.py index cf74bbdf6..aa79f4b48 100644 --- a/platypush/app/_app.py +++ b/platypush/app/_app.py @@ -464,10 +464,15 @@ class Application: self._run() +app: Optional[Application] = None + + def main(*args: str): """ Application entry point. """ + global app + app = Application.from_cmdline(args) try: