Merge lp:~danfairs/djangorecipe/extra-settings into lp:~jvloothuis/djangorecipe/trunk

Proposed by Dan Fairs
Status: Needs review
Proposed branch: lp:~danfairs/djangorecipe/extra-settings
Merge into: lp:~jvloothuis/djangorecipe/trunk
Diff against target: None lines
To merge this branch: bzr merge lp:~danfairs/djangorecipe/extra-settings
Reviewer Review Type Date Requested Status
Jeroen Vloothuis Pending
Review via email: mp+5654@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Dan Fairs (danfairs) wrote :

Hi,

This branch adds support for an extra-settings option, which allows extra settings to be inserted into the generated settings.py option. I needed this to be able to specify GeoDjango-related libraries (as shown in the updated README), but I thought it might be more generally useful.

Thanks,
Dan

Unmerged revisions

64. By Dan Fairs <email address hidden>

Updated documentation for the extra-settings option.

63. By Dan Fairs <email address hidden>

Rename extra_settings to extra-settings.

This naming is consistent with the current options naming
convention.

62. By Dan Fairs <email address hidden>

Added support for extra_settings.

This allows you to place an extra_settings section in your buildout, which
will be placed at the end of the generated settings.py file

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'README.txt'
2--- README.txt 2009-03-19 21:29:26 +0000
3+++ README.txt 2009-04-17 08:56:24 +0000
4@@ -56,6 +56,9 @@
5 production setup from your development setup. It defaults to
6 `development`.
7
8+extra-settings
9+ Extra settings that will be added to the generated settings.py file.
10+
11 download-cache
12 Set this to a folder somewhere on you system to speed up
13 installation. The recipe will use this folder as a cache for a
14@@ -78,7 +81,7 @@
15 An extra script is generated in the bin folder when this is set to
16 `true`. This can be used with mod_wsgi to deploy the project. The
17 name of the script is `control-script.wsgi`.
18-
19+
20 wsgilog
21 In case the WSGI server you're using does not allow printing to stdout,
22 you can set this variable to a filesystem path - all stdout/stderr data
23@@ -136,6 +139,9 @@
24 test =
25 someapp
26 anotherapp
27+ extra-settings =
28+ GDAL_LIBRARY_PATH = '/opt/lib/libgdal.dylib'
29+ GEOS_LIBRARY_PATH = '/opt/lib/libgeos_c.dylib'
30
31 Example using .pth files
32 ========================
33
34=== modified file 'src/djangorecipe/recipe.py'
35--- src/djangorecipe/recipe.py 2009-04-13 15:21:37 +0000
36+++ src/djangorecipe/recipe.py 2009-04-17 08:48:38 +0000
37@@ -73,7 +73,7 @@
38 os.path.join(os.path.dirname(__file__), "templates"),
39 )
40
41-
42+%(extra-settings)s
43 '''
44
45 production_settings = '''
46@@ -205,6 +205,9 @@
47 options.setdefault('fcgi', 'false')
48 options.setdefault('wsgilog', '')
49
50+ # Support for extra settings
51+ options.setdefault('extra-settings', '')
52+
53 # only try to download stuff if we aren't asked to install from cache
54 self.install_from_cache = self.buildout['buildout'].get(
55 'install-from-cache', '').strip() == 'true'
56@@ -361,6 +364,12 @@
57 template_vars = {'secret': self.generate_secret()}
58 template_vars.update(self.options)
59
60+ # Make sure extra settings are formatted so that there's no whitespace
61+ # at the start or end of each line
62+ extra_settings = '\n'.join(
63+ [line.strip() for line in self.options['extra-settings'].split('\n')])
64+ template_vars['extra-settings'] = extra_settings
65+
66 self.create_file(
67 os.path.join(project_dir, 'development.py'),
68 development_settings, template_vars)
69
70=== modified file 'src/djangorecipe/tests.py'
71--- src/djangorecipe/tests.py 2009-04-13 15:21:37 +0000
72+++ src/djangorecipe/tests.py 2009-04-17 08:48:38 +0000
73@@ -1,6 +1,7 @@
74 import unittest
75 import tempfile
76 import os
77+import re
78 import sys
79 import shutil
80
81@@ -352,6 +353,25 @@
82 manage = os.path.join(self.bin_dir, 'django')
83 self.assert_("djangorecipe.manage.main('project.spameggs')"
84 in open(manage).read())
85+
86+ def test_extra_settings(self):
87+ # The extra-settings option can be used to specify extra settings
88+ # at the bottom of the standard settings file.
89+ self.recipe.options['extra-settings'] = """
90+ PARROT = 'dead'
91+ NAILS = 4
92+ """
93+ project_dir = os.path.join(self.buildout_dir, 'project')
94+ self.recipe.create_project(project_dir)
95+ settings = os.path.join(project_dir, 'settings.py')
96+ result = open(settings).read()
97+ # Note that the string should be at the start of the line, regardless
98+ # of whitespace in the file
99+ flags = re.MULTILINE
100+ match = re.search("^PARROT = 'dead'$", result, flags)
101+ self.failIf(match is None)
102+ match = re.search("^NAILS = 4$", result, flags)
103+ self.failIf(match is None)
104
105 @mock.patch('urllib', 'urlretrieve')
106 def test_get_release(self, mock):

Subscribers

People subscribed via source and target branches

to all changes: