Merge ~cjwatson/launchpad:inline-appsetup into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 3e55bab17c634d3052ef243e2265323ffff87b5c
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:inline-appsetup
Merge into: launchpad:master
Diff against target: 86 lines (+34/-4)
3 files modified
lib/lp/services/webapp/wsgi.py (+34/-2)
requirements/launchpad.txt (+0/-1)
setup.py (+0/-1)
Reviewer Review Type Date Requested Status
Ioana Lasc (community) Approve
Review via email: mp+407100@code.launchpad.net

Commit message

Inline the relevant parts of zope.app.appsetup

Description of the change

zope.app.appsetup has relatively heavy dependencies (e.g. ZODB), and we don't need most of it. It's nearly as easy to do the small amount of it that we do need directly.

To post a comment you must log in.
Revision history for this message
Ioana Lasc (ilasc) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/lib/lp/services/webapp/wsgi.py b/lib/lp/services/webapp/wsgi.py
index 8749a80..c097d5a 100644
--- a/lib/lp/services/webapp/wsgi.py
+++ b/lib/lp/services/webapp/wsgi.py
@@ -10,15 +10,32 @@ __all__ = [
1010
11import logging11import logging
1212
13from zope.app.appsetup import appsetup
14from zope.app.wsgi import WSGIPublisherApplication13from zope.app.wsgi import WSGIPublisherApplication
14from zope.component.hooks import setHooks
15from zope.configuration import xmlconfig
16from zope.configuration.config import ConfigurationMachine
15from zope.event import notify17from zope.event import notify
18from zope.interface import implementer
16from zope.processlifetime import DatabaseOpened19from zope.processlifetime import DatabaseOpened
20from zope.security.interfaces import IParticipation
21from zope.security.management import (
22 endInteraction,
23 newInteraction,
24 system_user,
25 )
1726
18from lp.services.config import config27from lp.services.config import config
1928
2029
30@implementer(IParticipation)
31class SystemConfigurationParticipation(object):
32
33 principal = system_user
34 interaction = None
35
36
21def get_wsgi_application():37def get_wsgi_application():
38 # Loosely based on zope.app.appsetup.appsetup.
22 features = []39 features = []
23 if config.launchpad.devmode:40 if config.launchpad.devmode:
24 features.append("devmode")41 features.append("devmode")
@@ -26,7 +43,22 @@ def get_wsgi_application():
26 "Developer mode is enabled: this is a security risk and should "43 "Developer mode is enabled: this is a security risk and should "
27 "NOT be enabled on production servers. Developer mode can be "44 "NOT be enabled on production servers. Developer mode can be "
28 "turned off in launchpad-lazr.conf.")45 "turned off in launchpad-lazr.conf.")
29 appsetup.config("zcml/webapp.zcml", features=features)46
47 # Set user to system_user, so we can do anything we want.
48 newInteraction(SystemConfigurationParticipation())
49
50 # Hook up custom component architecture calls.
51 setHooks()
52
53 # Load server-independent site config.
54 context = ConfigurationMachine()
55 xmlconfig.registerCommonDirectives(context)
56 for feature in features:
57 context.provideFeature(feature)
58 context = xmlconfig.file("zcml/webapp.zcml", context=context)
59
60 # Reset user.
61 endInteraction()
3062
31 # We don't use ZODB, but the webapp subscribes to IDatabaseOpened to63 # We don't use ZODB, but the webapp subscribes to IDatabaseOpened to
32 # perform some post-configuration tasks, so emit that event manually.64 # perform some post-configuration tasks, so emit that event manually.
diff --git a/requirements/launchpad.txt b/requirements/launchpad.txt
index e770039..0b1eefa 100644
--- a/requirements/launchpad.txt
+++ b/requirements/launchpad.txt
@@ -170,7 +170,6 @@ WSGIProxy2==0.4.6
170wsgiref==0.1.2170wsgiref==0.1.2
171z3c.pt==3.2.0171z3c.pt==3.2.0
172z3c.ptcompat==2.2.0172z3c.ptcompat==2.2.0
173zope.app.appsetup==4.1.0
174zope.app.http==4.0.1173zope.app.http==4.0.1
175zope.app.publication==4.3.1174zope.app.publication==4.3.1
176zope.app.publisher==4.2.0175zope.app.publisher==4.2.0
diff --git a/setup.py b/setup.py
index 5c4f42d..a5f094a 100644
--- a/setup.py
+++ b/setup.py
@@ -248,7 +248,6 @@ setup(
248 'Werkzeug',248 'Werkzeug',
249 'WSGIProxy2',249 'WSGIProxy2',
250 'z3c.ptcompat',250 'z3c.ptcompat',
251 'zope.app.appsetup',
252 'zope.app.http',251 'zope.app.http',
253 'zope.app.publication',252 'zope.app.publication',
254 'zope.app.publisher',253 'zope.app.publisher',

Subscribers

People subscribed via source and target branches

to status/vote changes: