← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~cjwatson/launchpad/simplify-loggerhead-privacy into lp:launchpad

 

Colin Watson has proposed merging lp:~cjwatson/launchpad/simplify-loggerhead-privacy into lp:launchpad.

Commit message:
Simplify privacy detection in the loggerhead app now that translatePath tells us whether a branch is private.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/simplify-loggerhead-privacy/+merge/260279

Simplify privacy detection in the loggerhead app now that translatePath tells us whether a branch is private.  We don't need to fetch a URL and do fragile detection based on HTTP error codes any more.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/simplify-loggerhead-privacy into lp:launchpad.
=== modified file 'lib/launchpad_loggerhead/app.py'
--- lib/launchpad_loggerhead/app.py	2015-05-12 14:47:12 +0000
+++ lib/launchpad_loggerhead/app.py	2015-05-27 11:32:08 +0000
@@ -1,11 +1,10 @@
-# Copyright 2009-2013 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2015 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 import logging
 import os
 import threading
 import urllib
-import urllib2
 import urlparse
 import xmlrpclib
 
@@ -254,39 +253,11 @@
             if not os.path.isdir(cachepath):
                 os.makedirs(cachepath)
             self.log.info('branch_url: %s', branch_url)
-            base_api_url = allvhosts.configs['api'].rooturl
-            branch_api_url = '%s/%s/%s' % (
-                base_api_url,
-                'devel',
-                branch_name,
-                )
-            self.log.info('branch_api_url: %s', branch_api_url)
-            req = urllib2.Request(branch_api_url)
-            private = False
-            try:
-                # We need to determine if the branch is private
-                response = urllib2.urlopen(req)
-            except urllib2.HTTPError as response:
-                code = response.getcode()
-                if code in (400, 401, 403, 404):
-                    # There are several error codes that imply private data.
-                    # 400 (bad request) is a default error code from the API
-                    # 401 (unauthorized) should never be returned as the
-                    # requests are always from anon. If it is returned
-                    # however, the data is certainly private.
-                    # 403 (forbidden) is obviously private.
-                    # 404 (not found) implies privacy from a private team or
-                    # similar situation, which we hide as not existing rather
-                    # than mark as forbidden.
-                    self.log.info("Branch is private")
-                    private = True
-                self.log.info(
-                    "Branch state not determined; api error, return code: %s",
-                    code)
-                response.close()
+            private = info['private']
+            if private:
+                self.log.info("Branch is private")
             else:
                 self.log.info("Branch is public")
-                response.close()
 
             try:
                 bzr_branch = safe_open(


Follow ups