Colin Watson has proposed merging 
lp:~cjwatson/launchpad/git-repository-container into lp:launchpad with 
lp:~cjwatson/launchpad/refactor-launchpad-container as a prerequisite.

Commit message:
Add ILaunchpadContainer implementation for Git repositories.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/git-repository-container/+merge/287413

Add ILaunchpadContainer implementation for Git repositories.  It's an easy 
extension, and we're going to want this for caveats.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
lp:~cjwatson/launchpad/git-repository-container into lp:launchpad.
=== modified file 'lib/lp/code/configure.zcml'
--- lib/lp/code/configure.zcml	2016-01-11 19:16:04 +0000
+++ lib/lp/code/configure.zcml	2016-02-28 19:36:09 +0000
@@ -816,6 +816,10 @@
         interface="lp.code.interfaces.gitrepository.IGitRepositoryEdit"
         set_schema="lp.code.interfaces.gitrepository.IGitRepositoryEditableAttributes" />
   </class>
+  <adapter
+      for="lp.code.interfaces.gitrepository.IGitRepository"
+      provides="lp.services.webapp.interfaces.ILaunchpadContainer"
+      factory="lp.code.publisher.LaunchpadGitRepositoryContainer"/>
   <subscriber
       for="lp.code.interfaces.gitrepository.IGitRepository zope.lifecycleevent.interfaces.IObjectModifiedEvent"
       handler="lp.code.model.gitrepository.git_repository_modified"/>

=== modified file 'lib/lp/code/publisher.py'
--- lib/lp/code/publisher.py	2016-02-28 19:36:09 +0000
+++ lib/lp/code/publisher.py	2016-02-28 19:36:09 +0000
@@ -64,3 +64,13 @@
             self.context.target.context, ILaunchpadContainer)
         if adapter is not None:
             yield adapter
+
+
+class LaunchpadGitRepositoryContainer(LaunchpadContainer):
+
+    def getParentContainers(self):
+        """See `ILaunchpadContainer`."""
+        # A repository is within its target.
+        adapter = queryAdapter(self.context.target, ILaunchpadContainer)
+        if adapter is not None:
+            yield adapter

=== modified file 'lib/lp/registry/doc/launchpad-container.txt'
--- lib/lp/registry/doc/launchpad-container.txt	2016-02-28 19:36:09 +0000
+++ lib/lp/registry/doc/launchpad-container.txt	2016-02-28 19:36:09 +0000
@@ -120,3 +120,20 @@
     None
     >>> ILaunchpadContainer(junk).isWithin('/firefox')
     False
+
+
+== Git repositories ==
+
+A Git repository is within its target.
+
+    >>> sample_person = getUtility(IPersonSet).getByName('name12')
+    >>> firefox_git = factory.makeGitRepository(target=firefox)
+    >>> ILaunchpadContainer(firefox_git).isWithin('/firefox')
+    True
+    >>> ILaunchpadContainer(firefox_git).isWithin('/mozilla')
+    True
+
+But it's not within anything other than its target.
+
+    >>> ILaunchpadContainer(firefox_git).isWithin('/ubuntu/+source/evolution')
+    False

_______________________________________________
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to     : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp

Reply via email to