mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-04-29 10:10:19 +00:00
web_server: Drop use of loaded_modules and use App.list
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
528fd08245
commit
57422d562e
@ -5,11 +5,13 @@ Setup CherryPy web server.
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
import cherrypy
|
import cherrypy
|
||||||
|
|
||||||
from . import app, cfg, log, module_loader, web_framework
|
from . import app as app_module
|
||||||
|
from . import cfg, log, web_framework
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -57,13 +59,14 @@ def init():
|
|||||||
|
|
||||||
_mount_static_directory('/usr/share/javascript', '/javascript')
|
_mount_static_directory('/usr/share/javascript', '/javascript')
|
||||||
|
|
||||||
for module_name, module in module_loader.loaded_modules.items():
|
for app in app_module.App.list():
|
||||||
|
module = sys.modules[app.__module__]
|
||||||
module_path = os.path.dirname(module.__file__)
|
module_path = os.path.dirname(module.__file__)
|
||||||
static_dir = os.path.join(module_path, 'static')
|
static_dir = os.path.join(module_path, 'static')
|
||||||
if not os.path.isdir(static_dir):
|
if not os.path.isdir(static_dir):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
urlprefix = "%s%s" % (web_framework.get_static_url(), module_name)
|
urlprefix = "%s%s" % (web_framework.get_static_url(), app.app_id)
|
||||||
_mount_static_directory(static_dir, urlprefix)
|
_mount_static_directory(static_dir, urlprefix)
|
||||||
|
|
||||||
for component in StaticFiles.list():
|
for component in StaticFiles.list():
|
||||||
@ -88,7 +91,7 @@ def run(on_web_server_stop):
|
|||||||
cherrypy.engine.block()
|
cherrypy.engine.block()
|
||||||
|
|
||||||
|
|
||||||
class StaticFiles(app.FollowerComponent):
|
class StaticFiles(app_module.FollowerComponent):
|
||||||
"""Component to serve static files shipped with an app.
|
"""Component to serve static files shipped with an app.
|
||||||
|
|
||||||
Any files in <app>/static directory will be automatically served on
|
Any files in <app>/static directory will be automatically served on
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user