Merge lp:~jml/pkgme-service/buildout-wsgi into lp:pkgme-service

Proposed by Jonathan Lange
Status: Merged
Approved by: Jonathan Lange
Approved revision: 139
Merged at revision: 138
Proposed branch: lp:~jml/pkgme-service/buildout-wsgi
Merge into: lp:pkgme-service
Diff against target: 121 lines (+61/-0)
5 files modified
.bzrignore (+1/-0)
buildout-templates/django.wsgi.in (+49/-0)
buildout.cfg (+7/-0)
setup.py (+1/-0)
versions.cfg (+3/-0)
To merge this branch: bzr merge lp:~jml/pkgme-service/buildout-wsgi
Reviewer Review Type Date Requested Status
James Westby (community) Approve
Review via email: mp+132157@code.launchpad.net

Commit message

Build django.wsgi in buildout

Description of the change

I'm not sure if this will work, as I haven't tested it.

What I've done is added a buildout-templates/ directory, copied the WSGI
from memento, removed the path manipulation guff and replaced it with
something I picked up from Launchpad's buildout.

To post a comment you must log in.
Revision history for this message
James Westby (james-w) wrote :

Hi,

The first I encountered was that the relative path setup fails because mod_wsgi
does something funky when importing so that __name__ can't be found by imp.
I worked around this by putting the relative path stuff in the template and hacking
it to work for mod_wsgi.

The next issue was that none of the eggs were being imported because site was
already imported, so the buildout one wasn't being used. I worked around this by
altering the approach used. It doesn't isolate the app from site-packages, but I
don't see how it's possible to do that with mod_wsgi.

I've proposed my changes in to your branch so you can see what I did.

Thanks,

James

Revision history for this message
Jonathan Lange (jml) wrote :

On 30 October 2012 18:25, James Westby <email address hidden> wrote:
> Hi,
>
> The first I encountered was that the relative path setup fails because mod_wsgi
> does something funky when importing so that __name__ can't be found by imp.
> I worked around this by putting the relative path stuff in the template and hacking
> it to work for mod_wsgi.
>
> The next issue was that none of the eggs were being imported because site was
> already imported, so the buildout one wasn't being used. I worked around this by
> altering the approach used. It doesn't isolate the app from site-packages, but I
> don't see how it's possible to do that with mod_wsgi.
>
> I've proposed my changes in to your branch so you can see what I did.

Thanks, I've merged it into this one.

jml

Revision history for this message
James Westby (james-w) :
review: Approve
Revision history for this message
ISD Branch Mangler (isd-branches-mangler) wrote :

The attempt to merge lp:~jml/pkgme-service/buildout-wsgi into lp:pkgme-service failed. Below is the output from the failed tests.

Tree is up to date at revision 42 of branch bzr+ssh://bazaar.launchpad.net/+branch/ca-download-cache
Couldn't find index page for 'z3c.recipe.filetemplate' (maybe misspelled?)
While:
  Installing.
  Getting section filetemplates.
  Initializing section filetemplates.
  Installing recipe z3c.recipe.filetemplate.
  Getting distribution for 'z3c.recipe.filetemplate==2.2.0'.
Error: Couldn't find a distribution for 'z3c.recipe.filetemplate==2.2.0'.
make: *** [bin/py] Error 1

Revision history for this message
ISD Branch Mangler (isd-branches-mangler) wrote :

The attempt to merge lp:~jml/pkgme-service/buildout-wsgi into lp:pkgme-service failed. Below is the output from the failed tests.

Tree is up to date at revision 42 of branch bzr+ssh://bazaar.launchpad.net/+branch/ca-download-cache
Couldn't find index page for 'z3c.recipe.filetemplate' (maybe misspelled?)
While:
  Installing.
  Getting section filetemplates.
  Initializing section filetemplates.
  Installing recipe z3c.recipe.filetemplate.
  Getting distribution for 'z3c.recipe.filetemplate==2.2.0'.
Error: Couldn't find a distribution for 'z3c.recipe.filetemplate==2.2.0'.
make: *** [bin/py] Error 1

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2012-08-23 04:14:21 +0000
3+++ .bzrignore 2012-10-31 10:59:21 +0000
4@@ -18,3 +18,4 @@
5 ./eggs
6 ./parts
7 ./bin
8+django.wsgi
9
10=== added directory 'buildout-templates'
11=== added file 'buildout-templates/django.wsgi.in'
12--- buildout-templates/django.wsgi.in 1970-01-01 00:00:00 +0000
13+++ buildout-templates/django.wsgi.in 2012-10-31 10:59:21 +0000
14@@ -0,0 +1,49 @@
15+#!${buildout:executable} -S
16+
17+# Initialize our paths. This is the boilerplate that would be added by
18+# $${python-relative-path-setup} changed to work with mod_wsgi
19+import os, imp
20+# Get path to this file.
21+if __name__ == '__main__' or __name__.startswith("_mod_wsgi"):
22+ _z3c_recipe_filetemplate_filename = __file__
23+else:
24+ # If this is an imported module, we want the location of the .py
25+ # file, not the .pyc, because the .py file may have been symlinked.
26+ _z3c_recipe_filetemplate_filename = imp.find_module(__name__)[1]
27+# Get the full, non-symbolic-link directory for this file.
28+_z3c_recipe_filetemplate_base = os.path.dirname(
29+ os.path.abspath(os.path.realpath(_z3c_recipe_filetemplate_filename)))
30+# This is the buildout root.
31+def _z3c_recipe_filetemplate_path_repr(path):
32+ "Return absolute version of buildout-relative path."
33+ return os.path.join(_z3c_recipe_filetemplate_base, path)
34+import sys
35+sys.path[0:0] = [
36+ ${string-paths}
37+ ]
38+
39+import os
40+
41+os.environ['DJANGO_SETTINGS_MODULE'] = 'django_project.settings'
42+
43+from django.conf import settings
44+
45+# This is needed to workaround a bug in DJango, see the file it is
46+# implemented in for more details.
47+from oops_wsgi.django import OOPSWSGIHandler
48+
49+application = OOPSWSGIHandler()
50+
51+# Wrap the application in the Oops wsgi app to catch unhandled exceptions
52+# and create oops for them.
53+#
54+# First we create the config that defines what to do with the oopses.
55+
56+import oops_dictconfig
57+from oops_wsgi import make_app, install_hooks
58+
59+config = oops_dictconfig.config_from_dict(settings.OOPSES)
60+install_hooks(config)
61+
62+# Then we wrap the django app in the oops one
63+application = make_app(application, config, oops_on_status=['500'])
64
65=== modified file 'buildout.cfg'
66--- buildout.cfg 2012-10-25 14:29:16 +0000
67+++ buildout.cfg 2012-10-31 10:59:21 +0000
68@@ -4,6 +4,7 @@
69 [buildout]
70 parts =
71 scripts
72+ filetemplates
73 unzip = true
74 use-dependency-links = false
75 eggs-directory = eggs
76@@ -26,6 +27,12 @@
77
78 develop = .
79
80+
81+[filetemplates]
82+recipe = z3c.recipe.filetemplate
83+source-directory = buildout-templates
84+eggs = ${scripts:eggs}
85+
86 [scripts]
87 recipe = z3c.recipe.scripts
88 # Test dependencies get added here
89
90=== modified file 'setup.py'
91--- setup.py 2012-10-26 11:22:13 +0000
92+++ setup.py 2012-10-31 10:59:21 +0000
93@@ -29,6 +29,7 @@
94 'oops_datedir_repo==0.0.15',
95 'oops_celery==0.0.1',
96 'oops_dictconfig==0.0.1',
97+ 'oops_wsgi==0.0.10',
98 # The following are transitive dependencies, we're just fixing
99 # the versions.
100 'kombu==2.1.1',
101
102=== modified file 'versions.cfg'
103--- versions.cfg 2012-10-26 11:22:13 +0000
104+++ versions.cfg 2012-10-31 10:59:21 +0000
105@@ -43,6 +43,8 @@
106 oops_celery = 0.0.1
107 oops_datedir_repo = 0.0.15
108 oops_dictconfig = 0.0.1
109+oops_wsgi = 0.0.10
110+paste = 1.7.5.1
111 postgresfixture = 0.1.2
112 PIL = 1.1.7
113 piston-mini-client = 0.7.3
114@@ -66,6 +68,7 @@
115 txpkgme = 0.3
116 wadllib = 1.3.1
117 wsgi-intercept = 0.5.1
118+z3c.recipe.filetemplate = 2.2.0
119 z3c.recipe.scripts = 1.0.1
120 # Also upgrade the zc.buildout version in the Makefile's bin/buildout section.
121 zc.buildout = 1.5.1

Subscribers

People subscribed via source and target branches