Merge lp:~zyga/lava-dashboard/0.1.CONFIGURED-fix into lp:lava-dashboard/0.1

Proposed by Zygmunt Krynicki
Status: Merged
Merged at revision: 55
Proposed branch: lp:~zyga/lava-dashboard/0.1.CONFIGURED-fix
Merge into: lp:lava-dashboard/0.1
Diff against target: 271 lines (+150/-60)
6 files modified
INSTALL (+76/-25)
dashboard_server/default_settings.py (+5/-0)
dashboard_server/development_settings.py (+59/-0)
dashboard_server/local_settings.py.example (+0/-3)
dashboard_server/settings.py (+9/-26)
dashboard_server/urls.py (+1/-6)
To merge this branch: bzr merge lp:~zyga/lava-dashboard/0.1.CONFIGURED-fix
Reviewer Review Type Date Requested Status
Paul Larson (community) Needs Information
Review via email: mp+36920@code.launchpad.net

Description of the change

This branch adds an important bug fix to dashboard_server configuration.

Without this fix a set of development settings in settings.py will _always_ override customized local settings in local_settings.py

This branch fixes this by importing the variable CONFIGURED from local_settings.py (if it exists).

To post a comment you must log in.
Revision history for this message
Paul Larson (pwlars) wrote :

I'm not sure I like this approach. It depends on the administrator to know that they need to have CONFIGURED set to something in the local_settings. I realize the example has this, but why not just do something like:
try:
    from local_settings import *
except ImportError:
    ...do default config here

review: Needs Information
Revision history for this message
Zygmunt Krynicki (zyga) wrote :

> I'm not sure I like this approach. It depends on the administrator to know
> that they need to have CONFIGURED set to something in the local_settings. I
> realize the example has this, but why not just do something like:
> try:
> from local_settings import *
> except ImportError:
> ...do default config here

I agree with the downside. I wanted to have an option of always using local_settings.py (I use it for development to add some extra installed apps and middleware for development). How about we use this approach:

from default_settings import *
try:
    from local_settings import *
except ImportError:
    from development_settings import *

So there would be no CONFIGURED anymore and you could still use local_settings like I do (although you'd need to import development_settings inside your local settings for that).

56. By Zygmunt Krynicki

Rework configuration so that it's easier to get started

Revision history for this message
Zygmunt Krynicki (zyga) wrote :

Reworked as described in the previous comment. Please review as this needs to get out

Revision history for this message
Paul Larson (pwlars) wrote :

75 +SCRET_KEY = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
Should be SECRET_KEY

I'm not sure I understand adding development_settings.py rather than just have this in the default_settings.py or settings.py. I understand wanting to split it up to allow for easier configuration and the advantage of not having a single, monolithic settings file. However, the end result is complicated and non-standard. I feel like I need a map of what goes where, and what supersedes what. I would seriously consider simplifying this back down a bit unless there is a really good reason not to.

57. By Zygmunt Krynicki

Fix typo

58. By Zygmunt Krynicki

Improved installation instructions

Revision history for this message
Zygmunt Krynicki (zyga) wrote :

I need to get this out and release 0.1.1.
Merging despite lack of approve here

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'INSTALL'
2--- INSTALL 2010-09-23 02:18:48 +0000
3+++ INSTALL 2010-09-30 08:47:43 +0000
4@@ -1,25 +1,76 @@
5-The following script is suitable for installation in /opt (code & settings) and /srv (data).
6-(the script is meant to be read and executed manually, you need to interact with some steps)
7-
8- mkdir -p /opt/dashboard/
9- mkdir -p /srv/dashboard/media
10- bzr get lp:launch-control/0.1 /opt/dashboard/stable
11-
12- # Things to do here:
13- # 1) specify system administrators
14- # 2) set SECRET_KEY
15- # 3) configure database settings
16- # 4) confirm installation and data paths
17- cp /opt/dashboard/stable/dashboard_server/local_settings.py.example /opt/dashboard/stable/dashboard_server/local_settings.py
18- /opt/dashboard/stable/dashboard_server/manage.py syncdb
19- chown -R www-data.www-data /srv/dashboard/
20- cp /opt/dashboard/stable/dashboard_server/apache.conf /etc/apache2/sites-available/dashboard
21-
22- # Tweak to your preference, default is to have a *:80/dashboard/ virtual host
23- $EDITOR /etc/apache2/sites-available/dashboard
24- a2ensite dashboard
25- service apache restart
26-
27-Now go to your-site/dashboard/admin and sign-in with the username and password you provided.
28-Before the system can be used you must create an anonymous bundle stream. You can do this
29-by selecting "Bundle Streams" "Add" and "Save" from the admin panel.
30+Installation
31+============
32+
33+There are two possible options for installation right now:
34+
35+1) Run directly from the checkout (development and evaluation)
36+2) Install in /opt + /srv and configure to run via apache (production)
37+
38+The first option is attractive to anyone who just wants to try it out without
39+any hassle. The second option should be used if you plan on having a
40+continuous service.
41+
42+
43+Running directly from a checkout
44+================================
45+
46+There is very little you have to do, assuming you already have a checkout (if
47+you are reading this online and have bazaar installed you can get the latest
48+stable source directly from trunk with `bzr get lp:launch-control') you only
49+need to make sure you have required dependencies (see README)
50+
51+From within the source tree issue the following commands:
52+1) ./dashboard_server/manage.py syncdb
53+2) ./dashboard_server/manage.py runserver
54+
55+Then open your favourite browser and point it at http://localhost:8000/
56+
57+
58+Installation in /opt + /srv
59+===========================
60+
61+The following script is suitable for installation in /opt (code & settings)
62+and /srv (data). Tthe script is meant to be read and executed manually, you
63+need to interact with some steps
64+
65+# Setup space for code and data and fetch latest tree
66+sudo mkdir -p /opt/dashboard/
67+sudo mkdir -p /srv/dashboard/media
68+sudo chown www-data.www-data /srv/dashboard/
69+sudo bzr get lp:launch-control/0.1 /opt/dashboard/stable
70+
71+# Configure web server and dashboard for production deployment
72+sudo cp /opt/dashboard/stable/dashboard_server/local_settings.py.example /opt/dashboard/stable/dashboard_server/local_settings.py
73+# Things to do here:
74+# 1) specify system administrators
75+# 2) set SECRET_KEY to a random string
76+# 3) configure database settings (optional)
77+# 4) confirm installation and data paths (optional)
78+sudo $EDITOR /opt/dashboard/stable/dashboard_server/local_settings.py
79+# Note: here the system will interact with your database, if you configured
80+# something else than the default (sqlite) you must ensure that appropriate
81+# permissions are granted in advance.
82+# Note: if this is your first installation you will be prompted to create an
83+# administrator account. You should do so now. If you miss this step somehow
84+# you can issue 'createsuperuser' (instead of syncdb) command later.
85+sudo -u www-data /opt/dashboard/stable/dashboard_server/manage.py syncdb
86+
87+# Tweak to your preference, default is to have a *:80/dashboard/ virtual host
88+# Most likely you will want to change this, note that you _MUST_
89+# change local_settings.py if you want to choose another location for
90+# the dashboard (eg http://hostname/ vs http://hostname/dashboard/)
91+sudo cp /opt/dashboard/stable/dashboard_server/apache.conf /etc/apache2/sites-available/dashboard
92+sudo $EDITOR /etc/apache2/sites-available/dashboard
93+
94+# Enable dashboard app and restart apache
95+sudo a2ensite dashboard
96+sudo service apache restart
97+
98+
99+First run
100+=========
101+
102+Now go to http://your-site/dashboard/admin and sign-in with the username and
103+password you provided at syncdb or createsuperuser step. Before the system can
104+be used you must create an anonymous bundle stream. You can do this by
105+selecting "Bundle Streams" "Add" and "Save" from the admin panel.
106
107=== modified file 'dashboard_server/default_settings.py'
108--- dashboard_server/default_settings.py 2010-09-22 19:31:02 +0000
109+++ dashboard_server/default_settings.py 2010-09-30 08:47:43 +0000
110@@ -73,6 +73,9 @@
111 # to load the internationalization machinery.
112 USE_I18N = True
113
114+# Turn off application debugging
115+DEBUG = False
116+
117 # Turn on to enable template debugging.
118 TEMPLATE_DEBUG = False
119
120@@ -110,3 +113,5 @@
121 'django.contrib.databrowse',
122 'dashboard_app',
123 )
124+
125+SERVE_ASSETS_FROM_DJANGO = False
126
127=== added file 'dashboard_server/development_settings.py'
128--- dashboard_server/development_settings.py 1970-01-01 00:00:00 +0000
129+++ dashboard_server/development_settings.py 2010-09-30 08:47:43 +0000
130@@ -0,0 +1,59 @@
131+# Copyright (C) 2010 Linaro Limited
132+#
133+# Author: Zygmunt Krynicki <zygmunt.krynicki@linaro.org>
134+#
135+# This file is part of Launch Control.
136+#
137+# Launch Control is free software: you can redistribute it and/or modify
138+# it under the terms of the GNU Affero General Public License version 3
139+# as published by the Free Software Foundation
140+#
141+# Launch Control is distributed in the hope that it will be useful,
142+# but WITHOUT ANY WARRANTY; without even the implied warranty of
143+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
144+# GNU General Public License for more details.
145+#
146+# You should have received a copy of the GNU Affero General Public License
147+# along with Launch Control. If not, see <http://www.gnu.org/licenses/>.
148+
149+"""
150+Development settings module.
151+
152+Suitable for local deployments (local = not on the open web) as well as
153+hacking. Uses sqlite database and slow/inefficient web server built
154+right into Django.
155+"""
156+
157+import os
158+BASE_DIR = os.path.dirname(os.path.abspath(__file__))
159+
160+# Database setup
161+DATABASE_ENGINE = 'sqlite3'
162+DATABASE_NAME = os.path.join(BASE_DIR, 'database.db')
163+
164+# Static files are served directly from the source tree
165+MEDIA_ROOT = os.path.join(BASE_DIR, "media")
166+# Static files are accessible as /site_media/ URL
167+MEDIA_URL = '/site_media/'
168+
169+# Development mode, turn on debugging
170+# Note: debugging sucks memory as it retains SQL history _FOREVER_
171+# If you _really_ want to use this for local deployment please turn
172+# this off.
173+DEBUG = True
174+TEMPLATE_DEBUG = DEBUG
175+
176+# List of people that get emailed when the site breaks and DEBUG is off.
177+# Requires working email configuration
178+ADMINS = ()
179+
180+# Secret key for doing secret stuff with cookies and session IDs
181+SECRET_KEY = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
182+
183+# Information for urls.py that we should serve assets without the help
184+# of an external web server. This is only used when we cannot count on
185+# static media files being served by some real web server. WARNING: this
186+# is not secure and should _never_ be used in production environments.
187+# See:
188+# http://docs.djangoproject.com/en/1.2/howto/static-files/#the-big-fat-disclaimer)
189+SERVE_ASSETS_FROM_DJANGO = True
190
191=== modified file 'dashboard_server/local_settings.py.example'
192--- dashboard_server/local_settings.py.example 2010-09-22 19:53:28 +0000
193+++ dashboard_server/local_settings.py.example 2010-09-30 08:47:43 +0000
194@@ -11,6 +11,3 @@
195 MEDIA_ROOT = "/srv/dashboard/media/"
196 MEDIA_URL = '/dashboard/media/'
197 ADMIN_MEDIA_PREFIX = '/dashboard/admin/media/'
198-
199-DEBUG = False
200-CONFIGURED = True
201
202=== modified file 'dashboard_server/settings.py'
203--- dashboard_server/settings.py 2010-09-22 19:31:02 +0000
204+++ dashboard_server/settings.py 2010-09-30 08:47:43 +0000
205@@ -17,39 +17,22 @@
206 # along with Launch Control. If not, see <http://www.gnu.org/licenses/>.
207
208 """
209-Settings module suitable for development
210+Dashboard server settings module.
211 """
212
213 # CONFIGURATION
214 # =============
215 #
216-# To configure the server create local_settings.py and change the
217-# following line from `CONFIGURED = False' to `CONFIGURED = True'.
218-#
219-# Look at default_settings.py for explanation on what can be changed.
220-#
221-# When this is False a very simple configuration is created that allows
222-# you to run the server directly from the development environment.
223-CONFIGURED = False
224-
225+# To configure the server create local_settings.py and add any django
226+# configuration options you care about. Please look at
227+# local_settings.py.example to get started.
228+#
229 # DO NOT CHANGE SETTINGS BELOW
230 # ============================
231+
232 from default_settings import *
233
234-if not CONFIGURED:
235- DATABASE_ENGINE = 'sqlite3'
236- DATABASE_NAME = os.path.join(BASE_DIR, 'database.db')
237- MEDIA_ROOT = os.path.join(BASE_DIR, "media")
238- MEDIA_URL = '/site_media/'
239- DEBUG = True
240- TEMPLATE_DEBUG = DEBUG
241- ADMINS = ()
242- SECRET_KEY = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
243- try:
244- # You still might want this to configure email and
245- # administration stuff. I do this for development
246- from local_settings import *
247- except ImportError:
248- pass
249-else:
250+try:
251 from local_settings import *
252+except ImportError:
253+ from development_settings import *
254
255=== modified file 'dashboard_server/urls.py'
256--- dashboard_server/urls.py 2010-09-23 01:56:08 +0000
257+++ dashboard_server/urls.py 2010-09-30 08:47:43 +0000
258@@ -69,12 +69,7 @@
259 (r'^admin/', include(admin.site.urls)),
260 )
261
262-if not settings.CONFIGURED:
263- # This is only used when we cannot count on static media files being
264- # served by some real web server. WARNING: this is not secure and
265- # should _never_ be used in production environments.
266- # See:
267- # http://docs.djangoproject.com/en/1.2/howto/static-files/#the-big-fat-disclaimer)
268+if settings.SERVE_ASSETS_FROM_DJANGO:
269 urlpatterns += patterns('',
270 (r'^site_media/(?P<path>.*)$', 'django.views.static.serve', {
271 'document_root': settings.MEDIA_ROOT,

Subscribers

People subscribed via source and target branches