~jonas-drange/ubuntu-webcatalog/tos-redirect

« back to all changes in this revision

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

  • Committer: Anthony Lenton
  • Date: 2013-03-01 16:28:52 UTC
  • mfrom: (177.1.2 amqp-oopses)
  • Revision ID: anthony.lenton@canonical.com-20130301162852-3qm23gcaqdtud66m
[r=lukasz-czyzykowski] Display the oops id on every error page, and generate oops reports in dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#   -*- coding: utf-8 -*-
 
2
#   This file is part of the Apps Directory
 
3
#   Copyright (C) 2011-2013 Canonical Ltd.
 
4
#
 
5
#   This program is free software: you can redistribute it and/or modify
 
6
#   it under the terms of the GNU Affero General Public License as
 
7
#   published by the Free Software Foundation, either version 3 of the
 
8
#   License, or (at your option) any later version.
 
9
#
 
10
#   This program is distributed in the hope that it will be useful,
 
11
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
#   GNU Affero General Public License for more details.
 
14
#
 
15
#   You should have received a copy of the GNU Affero General Public License
 
16
#   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
17
 
 
18
"""Customized runserver command that runs ubuntu-webcatalog's wsgi stack."""
 
19
 
 
20
from optparse import make_option
 
21
from django.core.management.commands.runserver import BaseRunserverCommand
 
22
from django.core.servers.basehttp import AdminMediaHandler
 
23
 
 
24
 
 
25
class Command(BaseRunserverCommand):
 
26
    option_list = BaseRunserverCommand.option_list + (
 
27
        make_option(
 
28
            '--adminmedia', dest='admin_media_path', default='',
 
29
            help='Specifies the directory from which to serve admin media.'),
 
30
    )
 
31
 
 
32
    def get_handler(self, *args, **options):
 
33
        """Serves admin media like old-school (deprecation pending)."""
 
34
        from webcatalog.wsgi import make_app
 
35
        handler = make_app()
 
36
        return AdminMediaHandler(handler, options.get('admin_media_path', ''))