1
# Copyright 2011 Canonical Ltd. This software is licensed under the
2
# GNU Affero General Public License version 3 (see the file LICENSE).
4
"""Copy Policy Classes.
6
The classes contain various policies about copying packages that can be
7
decided at runtime, such as whether to auto-accept a package or not.
17
from lp.registry.interfaces.pocket import PackagePublishingPocket
18
from lp.registry.interfaces.series import SeriesStatus
22
"""Encapsulation of the policies for copying a package in Launchpad."""
24
def autoApprove(self, packageupload):
25
"""Decide if the packageupload can be approved automatically or
26
should be held in the queue.
28
raise AssertionError("Subclass must provide autoApprove")
30
def autoApproveNew(self, packageupload):
31
"""Decide if a previously unknown package is approved automatically
32
or should be held in the queue.
34
raise AssertionError("Subclass must provide autoApproveNew")
37
class InsecureCopyPolicy(BaseCopyPolicy):
38
"""A policy for copying from insecure sources."""
40
def autoApproveNew(self, packageupload):
41
if packageupload.isPPA():
45
def autoApprove(self, packageupload):
46
if packageupload.isPPA():
49
# This check is orthogonal to the
50
# IDistroSeries.canUploadToPocket check.
51
if (packageupload.pocket == PackagePublishingPocket.RELEASE and
52
packageupload.distroseries.status != SeriesStatus.FROZEN):