From patchwork Tue Nov 29 09:37:20 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zygmunt Krynicki X-Patchwork-Id: 5374 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 7111A23E17 for ; Tue, 29 Nov 2011 09:45:23 +0000 (UTC) Received: from mail-lpp01m010-f52.google.com (mail-lpp01m010-f52.google.com [209.85.215.52]) by fiordland.canonical.com (Postfix) with ESMTP id 48B11A18073 for ; Tue, 29 Nov 2011 09:45:23 +0000 (UTC) Received: by mail-lpp01m010-f52.google.com with SMTP id h2so1236092laa.11 for ; Tue, 29 Nov 2011 01:45:23 -0800 (PST) Received: by 10.152.135.225 with SMTP id pv1mr30690208lab.19.1322559923033; Tue, 29 Nov 2011 01:45:23 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.152.41.198 with SMTP id h6cs32958lal; Tue, 29 Nov 2011 01:45:22 -0800 (PST) Received: by 10.180.105.3 with SMTP id gi3mr8714465wib.36.1322559440782; Tue, 29 Nov 2011 01:37:20 -0800 (PST) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id fk15si17894597wbb.82.2011.11.29.01.37.20 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 29 Nov 2011 01:37:20 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) client-ip=91.189.90.7; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) smtp.mail=bounces@canonical.com Received: from ackee.canonical.com ([91.189.89.26]) by indium.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1RVK7s-0007L6-GS for ; Tue, 29 Nov 2011 09:37:20 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id 72AA9E0435 for ; Tue, 29 Nov 2011 09:37:20 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: lava-server X-Launchpad-Branch: ~linaro-validation/lava-server/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 322 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-validation/lava-server/trunk] Rev 322: Simplify configuration Message-Id: <20111129093720.13982.96606.launchpad@ackee.canonical.com> Date: Tue, 29 Nov 2011 09:37:20 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="14399"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: ace0e04bbf4eb1b837150e35b1670d0a32ca8576 ------------------------------------------------------------ revno: 322 committer: Zygmunt Krynicki branch nick: lava-server timestamp: Mon 2011-11-28 18:33:20 +0100 message: Simplify configuration This patch removes a lot of the duplication. It also changes how application expects to be installed in sub-URIs (this now has to come from the outside world). By default the configuration assumes it is mounted in / modified: lava_server/settings/common.py lava_server/settings/development.py lava_server/settings/production.py lava_server/urls.py --- lp:lava-server https://code.launchpad.net/~linaro-validation/lava-server/trunk You are subscribed to branch lp:lava-server. To unsubscribe from this branch go to https://code.launchpad.net/~linaro-validation/lava-server/trunk/+edit-subscription === modified file 'lava_server/settings/common.py' --- lava_server/settings/common.py 2011-10-11 09:20:14 +0000 +++ lava_server/settings/common.py 2011-11-28 17:33:20 +0000 @@ -72,8 +72,27 @@ "django.contrib.admin", ] -LOGIN_REDIRECT_URL = '/' - +# URL that handles the media served from MEDIA_ROOT. Make sure to use a +# trailing slash if there is a path component (optional in other cases). +# Examples: "http://media.lawrence.com", "http://example.com/media/" +MEDIA_URL = "/media/" + +# URL that handles the media served from STATIC_ROOT. Make sure to use a +# trailing slash if there is a path component (optional in other cases). +# Examples: "http://static.lawrence.com", "http://example.com/static/" +STATIC_URL = "/static/" + +# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a +# trailing slash. +# Examples: "http://foo.com/media/", "/media/". +ADMIN_MEDIA_PREFIX = "/static/admin/" + +# The true outer url is /lava-server/ +LOGIN_REDIRECT_URL = "/" + +# URL of the login screen, has to be hard-coded like that for Django. +# I cheat a little, using DATA_URL_PREFIX here is technically incorrect +# but it seems better than hard-coding 'lava-server' yet again. LOGIN_URL = '/accounts/login/' INSTALLED_APPS = [ === modified file 'lava_server/settings/development.py' --- lava_server/settings/development.py 2011-10-11 09:58:59 +0000 +++ lava_server/settings/development.py 2011-11-28 17:33:20 +0000 @@ -69,27 +69,6 @@ DEBUG_PROPAGATE_EXCEPTIONS = True TEMPLATE_DEBUG = DEBUG -# Application URL prefix defines where the application is located at -# runtime with regards to URLs. Data URL prefix does the same but for -# static and media files. -# -# Development settings use empty value to make localhost:8000 point -# to the application. Production values can use anything but this -# needs to be in sync with web server configuration. Debian -# recommends package name as the prefix so that multiple web -# applications can co-exists on one server without -# namespace clashes. -# -# The prefix _MUST_ end with a slash when not empty. - -# Code is served directly, WSGI mapping make it appear in "lava-server" but -# this is done externally to django URL resolver. -APP_URL_PREFIX = r"" -# Data is served by external web server in "lava-server/" -DATA_URL_PREFIX = r"" - - -# XXX: this is ugly! # It would be good to have rails-like configuration file in the future devel_db = os.getenv("DEVEL_DB", "sqlite") if devel_db == "pgsql": @@ -125,45 +104,31 @@ # Example: "/home/media/static.lawrence.com/" STATIC_ROOT = os.path.join(PROJECT_STATE_DIR, "static") -# URL that handles the media served from MEDIA_ROOT. Make sure to use a -# trailing slash if there is a path component (optional in other cases). -# Examples: "http://media.lawrence.com", "http://example.com/media/" -MEDIA_URL = "/" + DATA_URL_PREFIX + "media/" - -# URL that handles the media served from STATIC_ROOT. Make sure to use a -# trailing slash if there is a path component (optional in other cases). -# Examples: "http://static.lawrence.com", "http://example.com/static/" -STATIC_URL = "/" + DATA_URL_PREFIX + "static/" - -# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a -# trailing slash. -# Examples: "http://foo.com/media/", "/media/". -ADMIN_MEDIA_PREFIX = "/" + DATA_URL_PREFIX + "static/admin/" - -if not DEBUG: - raise Exception( - "You need to configure MEDIA_URL, STATIC_URL and ADMIN_MEDIA_PREFIX to" - "point to a production web server") # Make this unique, and don't share it with anybody. SECRET_KEY = '00000000000000000000000000000000000000000000000000' - +# Use templates from the checkout directory TEMPLATE_DIRS = ( os.path.join(PROJECT_SRC_DIR, "templates"), ) -STATICFILES_DIRS = [('lava-server', os.path.join(PROJECT_SRC_DIR, 'htdocs'))] - - +# Serve static files used by lava-server from the checkout directory +STATICFILES_DIRS = [ + ('lava-server', os.path.join(PROJECT_SRC_DIR, 'htdocs'))] + + +# Try using devserver if available, devserver is a very useful extension that +# makes debugging applications easier. It shows a lot of interesting output, +# like SQL queries and timings for each request. It also supports +# multi-threaded or multi-process server so some degree of parallelism can be +# achieved. try: import devserver INSTALLED_APPS += ['devserver'] except ImportError: pass -# Login redirects back to home -LOGIN_REDIRECT_URL = '/' # Any emails that would normally be sent are redirected to stdout. # This setting is only used for django 1.2 and newer. === modified file 'lava_server/settings/production.py' --- lava_server/settings/production.py 2011-10-11 09:20:14 +0000 +++ lava_server/settings/production.py 2011-11-28 17:33:20 +0000 @@ -21,50 +21,3 @@ DEBUG = False TEMPLATE_DEBUG = DEBUG - -# Application URL prefix defines where the application is located at -# runtime with regards to URLs. Data URL prefix does the same but for -# static and media files. -# -# Development settings use empty value to make localhost:8000 point -# to the application. Production values can use anything but this -# needs to be in sync with web server configuration. Debian -# recommends package name as the prefix so that multiple web -# applications can co-exists on one server without -# namespace clashes. -# -# Both values _MUST_ end with a slash when not empty. - -# Code is served directly, WSGI mapping make it appear in "lava-server" but -# this is done externally to django URL resolver. -APP_URL_PREFIX = r"" -# Data is served by external web server in "lava-server/" -DATA_URL_PREFIX = r"lava-server/" - -# URL that handles the media served from MEDIA_ROOT. Make sure to use a -# trailing slash if there is a path component (optional in other cases). -# Examples: "http://media.lawrence.com", "http://example.com/media/" -MEDIA_URL = "/" + DATA_URL_PREFIX + "media/" - -# URL that handles the media served from STATIC_ROOT. Make sure to use a -# trailing slash if there is a path component (optional in other cases). -# Examples: "http://static.lawrence.com", "http://example.com/static/" -STATIC_URL = "/" + DATA_URL_PREFIX + "static/" - -# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a -# trailing slash. -# Examples: "http://foo.com/media/", "/media/". -ADMIN_MEDIA_PREFIX = "/" + DATA_URL_PREFIX + "static/admin/" - -# The true outer url is /lava-server/ -LOGIN_REDIRECT_URL = "/" + DATA_URL_PREFIX - -# URL of the login screen, has to be hard-coded like that for Django. -# I cheat a little, using DATA_URL_PREFIX here is technically incorrect -# but it seems better than hard-coding 'lava-server' yet again. -LOGIN_URL = '/' + DATA_URL_PREFIX + 'accounts/login/' - -if DEBUG: - raise Exception( - "You should not run this application with debugging in a production" - " environment") === modified file 'lava_server/urls.py' --- lava_server/urls.py 2011-10-27 23:25:01 +0000 +++ lava_server/urls.py 2011-11-28 17:33:20 +0000 @@ -34,38 +34,38 @@ # Root URL patterns urlpatterns = patterns( '', - url(r'^' + settings.APP_URL_PREFIX + r'$', + url(r'^$', index, name='lava.home'), - url(r'^' + settings.APP_URL_PREFIX + r'me/$', + url(r'^me/$', me, name='lava.me'), - url(r'^' + settings.APP_URL_PREFIX + r'version/$', + url(r'^version/$', version, name='lava.version_details'), - url(r'^' + settings.APP_URL_PREFIX + r'accounts/', + url(r'^accounts/', include('django.contrib.auth.urls')), - url(r'^' + settings.APP_URL_PREFIX + r'admin/', + url(r'^admin/', include(admin.site.urls)), - url(r'^' + settings.APP_URL_PREFIX + r'openid/', + url(r'^openid/', include('django_openid_auth.urls')), - url(r'^' + settings.APP_URL_PREFIX + r'RPC2/', + url(r'^RPC2/', 'linaro_django_xmlrpc.views.handler', name='lava.api_handler', kwargs={ 'mapper': loader.xmlrpc_mapper, 'help_view': 'lava.api_help'}), - url(r'^' + settings.APP_URL_PREFIX + r'api/help/$', + url(r'^api/help/$', 'linaro_django_xmlrpc.views.help', name='lava.api_help', kwargs={ 'mapper': loader.xmlrpc_mapper}), - url(r'^' + settings.APP_URL_PREFIX + r'api/', + url(r'^api/', include(api_urls.token_urlpatterns)), # XXX: This is not needed but without it linaro-django-xmlrpc tests fail - url(r'^' + settings.APP_URL_PREFIX + r'api/', + url(r'^api/', include(api_urls.default_mapper_urlpatterns)), - url(r'^' + settings.APP_URL_PREFIX + r'utils/markitup/', + url(r'^utils/markitup/', include('lava_markitup.urls')))