diff mbox

[Branch,~linaro-validation/lava-server/trunk] Rev 322: Simplify configuration

Message ID 20111129093720.13982.96606.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

Zygmunt Krynicki Nov. 29, 2011, 9:37 a.m. UTC
------------------------------------------------------------
revno: 322
committer: Zygmunt Krynicki <zygmunt.krynicki@linaro.org>
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
diff mbox

Patch

=== 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')))