Merge lp:~mwhudson/launchpad/disable-vostok-when-not-configured into lp:launchpad

Proposed by Michael Hudson-Doyle
Status: Merged
Approved by: Paul Hummer
Approved revision: no longer in the source branch.
Merged at revision: 11307
Proposed branch: lp:~mwhudson/launchpad/disable-vostok-when-not-configured
Merge into: lp:launchpad
Diff against target: 35 lines (+14/-4)
1 file modified
lib/canonical/launchpad/webapp/metazcml.py (+14/-4)
To merge this branch: bzr merge lp:~mwhudson/launchpad/disable-vostok-when-not-configured
Reviewer Review Type Date Requested Status
Paul Hummer (community) code Approve
Review via email: mp+31901@code.launchpad.net

Commit message

make the publisher zcml directive do nothing if there is no corresponding config.vhost.$name section in the config

Description of the change

See the linked bug report, basically.

This uses the name in the publisher zcml directive to check if the factory should be registered. This works great for everything apart from shipit, so I special cased that.

Cheers,
mwh

To post a comment you must log in.
Revision history for this message
Paul Hummer (rockstar) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/canonical/launchpad/webapp/metazcml.py'
2--- lib/canonical/launchpad/webapp/metazcml.py 2010-07-22 02:44:32 +0000
3+++ lib/canonical/launchpad/webapp/metazcml.py 2010-08-05 22:01:12 +0000
4@@ -34,6 +34,7 @@
5 from z3c.ptcompat.zcml import page_directive as original_page
6 from z3c.ptcompat.zcml import pages_directive as original_pages
7
8+from canonical.config import config
9 from canonical.launchpad.layers import FeedsLayer
10 from canonical.launchpad.webapp.interfaces import (
11 IApplicationMenu, IAuthorization, ICanonicalUrlData, IContextMenu,
12@@ -655,10 +656,19 @@
13
14
15 def launchpadPublisher(_context, name, factory, methods=['*'],
16- mimetypes=['*'], priority=None):
17- # This overrides zope's definition of the <publisher> directive to supply
18- # an arbitrary unique priority if none is explicitly supplied -- we don't
19- # care about the priority in Launchpad but it needs to be unique.
20+ mimetypes=['*'], priority=None, vhost_name=None):
21+ # This overrides zope's definition of the <publisher> directive to
22+ # supply an arbitrary unique priority if none is explicitly
23+ # supplied -- we don't care about the priority in Launchpad but it
24+ # needs to be unique -- and to do nothing if no hostname is
25+ # configured for this publisher.
26+
27+ # shipit, uniquely, uses a different name in its <publisher>
28+ # directives to the name of the section in the config.
29+ if not name.startswith('shipit'):
30+ section = getattr(config.vhost, name, None)
31+ if section is None or section.hostname is None:
32+ return
33 global _arbitrary_priority
34 if priority is None:
35 _arbitrary_priority += 1