=== modified file 'lib/canonical/launchpad/security.py' --- lib/canonical/launchpad/security.py 2010-06-28 18:40:33 +0000 +++ lib/canonical/launchpad/security.py 2010-06-29 14:41:29 +0000 @@ -1703,10 +1703,12 @@ usedfor = IBranch def checkAuthenticated(self, user): + ssp_list = self.obj.associatedSuiteSourcePackages() + if ssp_list: + return can_upload_linked_package(user, self.obj, ssp_list) can_edit = ( user.inTeam(self.obj.owner) or - user_has_special_branch_access(user.person) or - can_upload_linked_package(user, self.obj)) + user_has_special_branch_access(user.person)) if can_edit: return True # It used to be the case that all import branches were owned by the @@ -1724,20 +1726,12 @@ and user.inTeam(code_import.registrant))) -def can_upload_linked_package(person_role, branch): +def can_upload_linked_package(person_role, branch, ssp_list): """True if person may upload the package linked to `branch`.""" - # No associated `ISuiteSourcePackage` data -> not an official branch. - # Abort. - ssp_list = branch.associatedSuiteSourcePackages() - if len(ssp_list) < 1: - return False - - # XXX al-maisan, 2009-10-20: a branch may currently be associated with a - # number of (distroseries, sourcepackagename, pocket) combinations. - # This does not seem right. But until the database model is fixed we work - # around this by assuming that things are fine as long as we find at least - # one combination that allows us to upload the corresponding source - # package. + # A branch may currently be associated with a number of (distroseries, + # sourcepackagename, pocket) combinations. A user can edit the branch as + # long as there the user can upload to the archive for at least one + # combination. for ssp in ssp_list: archive = ssp.sourcepackage.get_default_archive() if archive.canUploadSuiteSourcePackage(person_role.person, ssp):