plugins - Python complex app design -
i'm trying develop small application submodules (plugins). far understand principle of plug-ins - each plugin app instance on init, this:
from plugins import plug1, plug2 utils import logger, api class app(object): def __init__(self): self.log = logger() self.api = api() self.plugins = [] self.plugins.append(plug1(self)) self.plugins.append(plug2(self)) class plug1(object): def __init__(self, app): self.app = app class plug2(object): def __init__(self, app): self.app = app app class has attributes logger , network api. how more correct use them in plugin? use self.app.log , self.app.api.func1() or make shortlinks like
class plug1(object): def __init__(self, app): self.app = app self.log = app.log self.api = app.api or maybe i'm totaly wrong application structure?
Comments
Post a Comment