<div dir="ltr">This all sounds wonderful.<div><br></div><div>Just to clarify the assertion "<span style="font-size:12.8px">Don't use entry points for anything else"</span>, I assume we will continue to use entry points for pulp-admin to load "extensions" that are provided by plugins.</div><div><br></div><div>Michael</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Sep 1, 2016 at 4:55 PM, Sean Myers <span dir="ltr"><<a href="mailto:sean.myers@redhat.com" target="_blank">sean.myers@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This morning we had an ad hoc discussion regarding the naming/namespacing<br>
of our django apps in the Pulp platform and its plugins in Pulp 3. While<br>
we were there we also talked a little bit about the pulp plugin API namespace,<br>
and how we plan to "register" our plugin apps with Django.<br>
<br>
I'll outline my recollection of the main points here, and elaborate below.<br>
This is all from memory (I forgot to take notes...), so please correct anything<br>
I've gotten wrong.<br>
<br>
- All Django apps should be named <package>.app<br>
  - Rename pulp.platform to pulp.app (pulp.platform is currently the platform<br>
    django app)<br>
  - Plugins should also follow this naming scheme<br>
- Plugin API should be exposed under pulp.plugin(s). Anything importable<br>
  from this namespace should be considered part of the versioned plugin API<br>
- Use Django's Applications framework (linked below) to initialize plugins<br>
  - Use python entry points to discover plugin Django apps and add them to<br>
    INSTALLED_APPS<br>
  - Don't use entry points for anything else<br>
  - Do use Django's AppConfig to trigger any needed plugin initialization<br>
    functionality<br>
<br>
The details!<br>
<br>
<br>
= All Django apps should be named <package>.app<br>
<br>
Currently, no plugins have created Django apps for Pulp 3. The platform<br>
Django app is 'pulp.platform' itself. For simplicity's sake, the consensus<br>
was to call the Django apps "app". It's brief, and at least in the Django<br>
context it makes it clear that this is what gets added to Django's<br>
INSTALLED_APPS list to make the plugin known to Django.<br>
<br>
Since pulp.platform currently is the platform Django app, the proposal is<br>
to rename pulp.platform to pulp.app.<br>
<br>
This work is tracked in <a href="https://pulp.plan.io/issues/2226" rel="noreferrer" target="_blank">https://pulp.plan.io/issues/<wbr>2226</a>, including details<br>
about the open PRs we'd like to see closed before renaming pulp.platform.<br>
Please update that issue as appropriate if I missed any 3.0-related pull<br>
requests that might be affected by the pulp.platform rename.<br>
<br>
The plugins have not yet been converted, but when Django apps are created<br>
in the plugins, they should be similarly named. So, for example, rpm's<br>
Django app will be pulp_rpm.app, docker will will be pulp_docker.app, etc.<br>
<br>
<br>
= Plugin API should be exposed under pulp.plugin(s)<br>
<br>
We touched on a few other topics, including namespacing the entire plugin<br>
API under pulp.plugin, so that plugin writers would ideally only ever<br>
"from pulp.plugin import what_they_need". pulp.plugin was used interchangeably<br>
with pulp.plugins (I prefer the former but don't care). Explicitly<br>
exposing this namespace as "the plugin API" (hopefully) makes it easier to<br>
manage semantic versioning here. This would mean, for example, importing<br>
base models that we want to expose to plugins into a module named like<br>
"pulp.plugins.models". In this example, the plugins would therefore *not*<br>
import any models from pulp.app.models.<br>
<br>
This might be infeasible; Brian is taking it into account while working on<br>
<a href="https://pulp.plan.io/issues/2181" rel="noreferrer" target="_blank">https://pulp.plan.io/issues/<wbr>2181</a><br>
<br>
= Use Django's Applications framework to initialize plugins<br>
<br>
Finally, I mentioned my thoughts about how we would use Django's apps framework<br>
as the basis for all plugin capability discovery. The gist is that "we'll use it<br>
exactly how Django says to use it", as described in their docs:<br>
<br>
<a href="https://docs.djangoproject.com/en/1.8/ref/applications/" rel="noreferrer" target="_blank">https://docs.djangoproject.<wbr>com/en/1.8/ref/applications/</a><br>
<br>
Specifically applied to pulp, we're most likely going to use entry points to<br>
make the installed plugins discoverable as Django apps and get them added to<br>
Django's INSTALLED_APPS. From there, my current thinking is that we'll have<br>
a specialized AppConfig subclass that plugins will use to uniformly register<br>
their required and optional functionality with the Pulp platform. We get some<br>
of this "for free", like models discovery, by virtue of using Django, so I'm<br>
thinking that this specifically relates to things like making sure the API is<br>
made aware of new views that it'll need to expose, tasks get loaded, or any<br>
other initialization-time functionality we might want.<br>
<br>
<br>______________________________<wbr>_________________<br>
Pulp-dev mailing list<br>
<a href="mailto:Pulp-dev@redhat.com">Pulp-dev@redhat.com</a><br>
<a href="https://www.redhat.com/mailman/listinfo/pulp-dev" rel="noreferrer" target="_blank">https://www.redhat.com/<wbr>mailman/listinfo/pulp-dev</a><br>
<br></blockquote></div><br></div>