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`.
This commit is contained in:
Fabio Manganiello 2023-04-29 15:50:31 +02:00
parent 68d8befa34
commit a20065c649
Signed by untrusted user: blacklight
GPG key ID: D90FBA7F76362774

View file

@ -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