launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #27198
[Merge] ~twom/launchpad:add-restricted-files-to-spph-api into launchpad:master
Tom Wardill has proposed merging ~twom/launchpad:add-restricted-files-to-spph-api into launchpad:master.
Commit message:
Add has_restricted_files to SPPH API.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #1931233 in Launchpad itself: "source_package_publishing_history entries may be embargoed, consider exposing this in the API"
https://bugs.launchpad.net/launchpad/+bug/1931233
For more details, see:
https://code.launchpad.net/~twom/launchpad/+git/launchpad/+merge/403967
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~twom/launchpad:add-restricted-files-to-spph-api into launchpad:master.
diff --git a/lib/lp/soyuz/interfaces/publishing.py b/lib/lp/soyuz/interfaces/publishing.py
index fe1c424..b274487 100644
--- a/lib/lp/soyuz/interfaces/publishing.py
+++ b/lib/lp/soyuz/interfaces/publishing.py
@@ -25,6 +25,7 @@ __all__ = [
'name_priority_map',
]
+import email
from lazr.restful.declarations import (
call_with,
error_status,
@@ -318,6 +319,11 @@ class ISourcePackagePublishingHistoryPublic(IPublishingView):
title=_('Reason why this publication is going to be removed.'),
required=False, readonly=False,
))
+ has_restricted_files = exported(
+ Bool(
+ title=_("Whether or not a given source files has restricted files."),
+ required=False, readonly=False
+ ))
meta_sourcepackage = Attribute(
"Return an ISourcePackage meta object correspondent to the "
diff --git a/lib/lp/soyuz/model/publishing.py b/lib/lp/soyuz/model/publishing.py
index 2c84740..40cac14 100644
--- a/lib/lp/soyuz/model/publishing.py
+++ b/lib/lp/soyuz/model/publishing.py
@@ -619,6 +619,18 @@ class SourcePackagePublishingHistory(SQLBase, ArchivePublisherBase):
getUtility(IPublishingSet).requestDeletion(
[self], removed_by, removal_comment)
+ def has_restricted_files(self):
+ """See ISourcePackagePublishingHistory."""
+ for source_file in self.sourcepackagerelease.files:
+ if source_file.libraryfile.restricted:
+ return True
+
+ for binary in self.getBuiltBinaries():
+ for binary_file in binary.binarypackagerelease.files:
+ if binary_file.libraryfile.restricted:
+ return True
+
+ return False
@implementer(IBinaryPackagePublishingHistory)
class BinaryPackagePublishingHistory(SQLBase, ArchivePublisherBase):
diff --git a/lib/lp/soyuz/scripts/packagecopier.py b/lib/lp/soyuz/scripts/packagecopier.py
index 2e4a767..eabc7de 100644
--- a/lib/lp/soyuz/scripts/packagecopier.py
+++ b/lib/lp/soyuz/scripts/packagecopier.py
@@ -111,21 +111,6 @@ def update_files_privacy(pub_record):
return changed_files
-# XXX cprov 2009-07-01: should be part of `ISourcePackagePublishingHistory`.
-def has_restricted_files(source):
- """Whether or not a given source files has restricted files."""
- for source_file in source.sourcepackagerelease.files:
- if source_file.libraryfile.restricted:
- return True
-
- for binary in source.getBuiltBinaries():
- for binary_file in binary.binarypackagerelease.files:
- if binary_file.libraryfile.restricted:
- return True
-
- return False
-
-
@delegate_to(ISourcePackagePublishingHistory)
class CheckedCopy:
"""Representation of a copy that was checked and approved.
@@ -508,7 +493,7 @@ class CopyChecker:
(ancestry.displayname, ancestry.distroseries.name))
requires_unembargo = (
- not self.archive.private and has_restricted_files(source))
+ not self.archive.private and source.has_restricted_files())
if requires_unembargo and not self.unembargo:
raise CannotCopy(
@@ -663,7 +648,7 @@ def do_copy(sources, archive, series, pocket, include_binaries=False,
announce_from_person=announce_from_person,
previous_version=old_version, logger=logger)
mailer.sendAll()
- if not archive.private and has_restricted_files(source):
+ if not archive.private and source.has_restricted_files():
# Fix copies by unrestricting files with privacy mismatch.
# We must do this *after* calling mailer.sendAll (which only
# actually sends mail on commit), because otherwise the new