~allenap/maas/docs-and-man-bug-975454

« back to all changes in this revision

Viewing changes to src/maasserver/management/commands/runserver.py

  • Committer: Jeroen Vermeulen
  • Date: 2012-02-07 18:14:14 UTC
  • mto: This revision was merged to the branch mainline in revision 92.
  • Revision ID: jeroen.vermeulen@canonical.com-20120207181414-3mtmupvvksyrwv2d
Basic setup for a metadata server.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
    )
22
22
 
23
23
 
 
24
error_template = """
 
25
<html>
 
26
<head><title>Oops! - %(id)s</title></head>
 
27
<body>
 
28
<h1>Oops!</h1>
 
29
<p>
 
30
  Something broke while generating this page.
 
31
</p>
 
32
<p>
 
33
  If the problem persists, please
 
34
  <a href="https://bugs.launchpad.net/maas/">file a bug</a>.  Make a note of
 
35
  the "oops id": <strong>%(id)s</strong>
 
36
</html>
 
37
""".lstrip()
 
38
 
 
39
 
 
40
def render_error(report):
 
41
    """Produce an HTML error report, in raw bytes (not unicode)."""
 
42
    return (error_template % report).encode('ascii')
 
43
 
 
44
 
24
45
class Command(BaseRunserverCommand):
25
46
    """Customized "runserver" command that wraps the WSGI handler."""
26
47
 
38
59
        oops_repository = DateDirRepo(settings.OOPS_REPOSITORY, 'maasserver')
39
60
        oops_config.publishers.append(oops_repository.publish)
40
61
        install_hooks(oops_config)
41
 
        return make_app(wsgi_handler, oops_config)
 
62
        return make_app(wsgi_handler, oops_config, error_render=render_error)