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
=== modified file 'lib/canonical/launchpad/webapp/metazcml.py'
--- lib/canonical/launchpad/webapp/metazcml.py 2010-07-22 02:44:32 +0000
+++ lib/canonical/launchpad/webapp/metazcml.py 2010-08-05 22:01:12 +0000
@@ -34,6 +34,7 @@
34from z3c.ptcompat.zcml import page_directive as original_page34from z3c.ptcompat.zcml import page_directive as original_page
35from z3c.ptcompat.zcml import pages_directive as original_pages35from z3c.ptcompat.zcml import pages_directive as original_pages
3636
37from canonical.config import config
37from canonical.launchpad.layers import FeedsLayer38from canonical.launchpad.layers import FeedsLayer
38from canonical.launchpad.webapp.interfaces import (39from canonical.launchpad.webapp.interfaces import (
39 IApplicationMenu, IAuthorization, ICanonicalUrlData, IContextMenu,40 IApplicationMenu, IAuthorization, ICanonicalUrlData, IContextMenu,
@@ -655,10 +656,19 @@
655656
656657
657def launchpadPublisher(_context, name, factory, methods=['*'],658def launchpadPublisher(_context, name, factory, methods=['*'],
658 mimetypes=['*'], priority=None):659 mimetypes=['*'], priority=None, vhost_name=None):
659 # This overrides zope's definition of the <publisher> directive to supply660 # This overrides zope's definition of the <publisher> directive to
660 # an arbitrary unique priority if none is explicitly supplied -- we don't661 # supply an arbitrary unique priority if none is explicitly
661 # care about the priority in Launchpad but it needs to be unique.662 # supplied -- we don't care about the priority in Launchpad but it
663 # needs to be unique -- and to do nothing if no hostname is
664 # configured for this publisher.
665
666 # shipit, uniquely, uses a different name in its <publisher>
667 # directives to the name of the section in the config.
668 if not name.startswith('shipit'):
669 section = getattr(config.vhost, name, None)
670 if section is None or section.hostname is None:
671 return
662 global _arbitrary_priority672 global _arbitrary_priority
663 if priority is None:673 if priority is None:
664 _arbitrary_priority += 1674 _arbitrary_priority += 1