Use Django dispatcher instead of CherryPy dispatcher

This commit is big because anything small breaks the code.

- Django dispatcher is based on regular expressions and does not need a tree structure
- Reduces a lot of unnecessary dependencies among modules
- Use Django sessions middlewear instead of CherryPy sessions
- Introduce dependency based modules instead of numeric load order
- Remove PagePlugin and simply use Django views
- Eliminate page rendering wrappers in favor of Django context processors
- Use custom auth for now until replaced by Django auth middlewear
- Use Django templated 404 and 500 error pages
This commit is contained in:
Sunil Mohan Adapa committed 2014-06-12 23:33:25 +05:30
1 parent 657bb11bbc
commit 58d13e3ed8
42 files changed
+1281 -1289

No files matched your search

+4 -2
View File
@@ -16,10 +16,12 @@
#
"""
Plinth module to system diagnostics
Plinth module for system diagnostics
"""
from . import diagnostics
from .diagnostics import init
__all__ = ['diagnostics', 'init']
__all__ = ['diagnostics']
DEPENDS = ['system']
+20 -29
View File
@@ -19,41 +19,32 @@
Plinth module for running diagnostics
"""
import cherrypy
from gettext import gettext as _
from ..lib.auth import require
from plugin_mount import PagePlugin
from django.template.response import TemplateResponse
import actions
import cfg
import util
from ..lib.auth import login_required
class Diagnostics(PagePlugin):
order = 30
def __init__(self):
super(Diagnostics, self).__init__()
def init():
"""Initialize the module"""
menu = cfg.main_menu.find('/sys')
menu.add_item("Diagnostics", "icon-screenshot", "/sys/diagnostics", 30)
self.register_page("sys.diagnostics")
cfg.html_root.sys.menu.add_item("Diagnostics", "icon-screenshot", "/sys/diagnostics", 30)
@cherrypy.expose
@require()
def index(self):
return util.render_template(template='diagnostics',
title=_('System Diagnostics'))
@login_required
def index(request):
"""Serve the index page"""
return TemplateResponse(request, 'diagnostics.html',
{'title': _('System Diagnostics')})
class Test(PagePlugin):
order = 31
def __init__(self):
super(Test, self).__init__()
self.register_page("sys.diagnostics.test")
@cherrypy.expose
@require()
def index(self):
output, error = actions.superuser_run("diagnostic-test")
return util.render_template(template='diagnostics_test',
title=_('Diagnostic Test'),
diagnostics_output=output,
diagnostics_error=error)
@login_required
def test(request):
"""Run diagnostics and the output page"""
output, error = actions.superuser_run("diagnostic-test")
return TemplateResponse(request, 'diagnostics_test.html',
{'title': _('Diagnostic Test'),
'diagnostics_output': output,
'diagnostics_error': error})