From a20065c6494ea7895bdf6b9787a9d0a5bf3973f4 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sat, 29 Apr 2023 15:50:31 +0200 Subject: [PATCH] Exposed `_entities` utility property in `Plugin`. It can be used by other plugins to easily access the `entities` plugin, along the lines of `db` and `redis`. --- platypush/plugins/__init__.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/platypush/plugins/__init__.py b/platypush/plugins/__init__.py index c57ffd678..fa6f5617e 100644 --- a/platypush/plugins/__init__.py +++ b/platypush/plugins/__init__.py @@ -91,6 +91,18 @@ class Plugin(EventGenerator, ExtensionWithManifest): # lgtm [py/missing-call-to assert redis, 'db plugin not initialized' return redis + @property + def _entities(self): + """ + :return: The reference to the :class:`platypush.plugins.entities.EntitiesPlugin`. + """ + from platypush.context import get_plugin + from platypush.plugins.entities import EntitiesPlugin + + entities: EntitiesPlugin = get_plugin(EntitiesPlugin) # type: ignore + assert entities, 'entities plugin not initialized' + return entities + def run(self, method, *args, **kwargs): assert ( method in self.registered_actions