Skip to content
This repository has been archived by the owner on Dec 7, 2022. It is now read-only.
/ pulp Public archive

Commit

Permalink
Adds importing of the 'content' module
Browse files Browse the repository at this point in the history
The 'content' module needs to be auto-imported when the content app
starts so that loading is added to its startup sequence with this PR.
Importing is all we have to do and aiohttp's registration mechanisms
take over.

https://pulp.plan.io/issues/4273
re #4273
  • Loading branch information
Brian Bouterse committed Dec 18, 2018
1 parent a63cdeb commit 21576ca
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions pulpcore/content/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
from aiohttp import web
from contextlib import suppress
from importlib import import_module

from aiohttp import web
from django.conf import settings
from pulpcore.app.apps import pulp_plugin_configs

from .handler import Handler


handler = Handler()
app = web.Application()

CONTENT_MODULE_NAME = 'content'


async def server(*args, **kwargs):
app = web.Application()
app.add_routes([web.get(settings.CONTENT_PATH_PREFIX + '{path:.+}', handler.stream_content)])
for pulp_plugin in pulp_plugin_configs():
if pulp_plugin.name != "pulpcore.app":
content_module_name = '{name}.{module}'.format(name=pulp_plugin.name,
module=CONTENT_MODULE_NAME)
with suppress(ModuleNotFoundError):
import_module(content_module_name)
app.add_routes([web.get(settings.CONTENT_PATH_PREFIX + '{path:.+}', Handler().stream_content)])
return app

0 comments on commit 21576ca

Please sign in to comment.