===================================== 20131205 (Thursday, 05 December 2013) ===================================== Plugins are Apps ---------------- I continued to think about what Joe and I had called "plugins". And ha, I understood something! Excerpt from a mail I wrote to Joe on November 18: Difference between plugins and apps: The nature of plugins is to be another level of modularization besides apps, another direction of applying our analytic knife when describing a complex system (in case you have read "Zen and the Art of Motorcycle Maintenance"). Plugins can require certain apps to be installed, but the list of installed apps does *not* automatically lead to a list of *installed* plugins. This is why I have `get_installed_plugins`. The thing I understood is that the above paragraph is bullshit. The direction of your analytic knife should not depend on the fact whether it is a plugin or an app. So I merged the classes `Plugin` and `App` and converted our proof-of-concept plugin (`BeIdReaderPlugin`) into an app (named :mod:`lino.apps.beid`). The former `BeIdJsLibPlugin` is now in :mod:`lino.apps.eid_jslib.beid`. It overrides :mod:`lino.apps.beid`, that's why it must have the same app_label. Here is the content of `lino/apps`:: . ├── beid └── eid_jslib └── beid Note that I hereby started to grow new apps in a package :mod:`lino.apps` instead of :mod:`lino.modlib`. TODO: - move also the `setup_xxx_menu` methods from models module to App - write documentation Now before going on it's really time to get all test suites up and running again. The suites for :ref:`patrols`, :ref:`faggio` and :ref:`welfare` had been broken for some time. Now they pass again. I also had neglected the :xfile:`userdocs` directories, now they all build again without any warning. Moved `get_installed_plugins` method from :mod:`lino` to :mod:`djangosite`. Because intuitively I'd say that this is a better place for it. This should make no difference for applications. One subtle difference is that ``"lino"`` is no longer at the end just before ``"djangosite"``. Replace `SiteMixin` hacks by `App` usages ----------------------------------------- A first positive effect of today's work: I can remove the `SiteMixin` classes from :mod:`lino.modlib.vat` and :mod:`lino_welfare.modlib.cbss`! And the latter even protect myself from forgetting to convert local settings files because I added an error message in that case. Summary: Every Django app which defines a class object called "App" in its main module (not in the models module) now gets some special functionality: the class object will be instiantiated exactly once when the Site instantiates (i.e. before Django settings are ready), and this object is stored (under the app_label as key), in `settings.SITE.plugins`. That's really cool! (Just a pity that these human bodies need to sleep every now and then ;-) Don't hesitate to contact me directly and ask questions, because this is complex stuff, and I won't have time until end of January to document it as it would deserve. TODO: - Convert lino.extjs to a plugin (oops, i mean "an app with an :class:`ad.App `").