~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/registry/interfaces/distribution.py

  • Committer: Danilo Segan
  • Date: 2011-04-22 14:02:29 UTC
  • mto: This revision was merged to the branch mainline in revision 12910.
  • Revision ID: danilo@canonical.com-20110422140229-zhq4d4c2k8jpglhf
Ignore hidden files when building combined JS file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright 2009-2011 Canonical Ltd.  This software is licensed under the
 
1
# Copyright 2009 Canonical Ltd.  This software is licensed under the
2
2
# GNU Affero General Public License version 3 (see the file LICENSE).
3
3
 
4
4
# pylint: disable-msg=E0211,E0213
22
22
 
23
23
from lazr.lifecycle.snapshot import doNotSnapshot
24
24
from lazr.restful.declarations import (
25
 
    call_with,
26
25
    collection_default_content,
27
26
    export_as_webservice_collection,
28
27
    export_as_webservice_entry,
29
28
    export_operation_as,
30
29
    export_read_operation,
31
30
    exported,
32
 
    operation_for_version,
33
31
    operation_parameters,
34
32
    operation_returns_collection_of,
35
33
    operation_returns_entry,
36
34
    rename_parameters_as,
37
 
    REQUEST_USER,
38
35
    )
39
36
from lazr.restful.fields import (
40
37
    CollectionField,
55
52
    TextLine,
56
53
    )
57
54
 
58
 
from lp import _
59
 
from lp.answers.interfaces.questiontarget import IQuestionTarget
 
55
from canonical.launchpad import _
 
56
from canonical.launchpad.interfaces.launchpad import (
 
57
    IHasAppointedDriver,
 
58
    IHasDrivers,
 
59
    )
60
60
from lp.app.errors import NameLookupFailed
61
61
from lp.app.interfaces.headings import IRootContext
62
62
from lp.app.interfaces.launchpad import (
83
83
    ICanGetMilestonesDirectly,
84
84
    IHasMilestones,
85
85
    )
86
 
from lp.registry.interfaces.oopsreferences import IHasOOPSReferences
87
86
from lp.registry.interfaces.pillar import IPillar
88
 
from lp.registry.interfaces.role import (
89
 
    IHasAppointedDriver,
90
 
    IHasDrivers,
91
 
    IHasOwner,
92
 
    )
 
87
from lp.registry.interfaces.role import IHasOwner
93
88
from lp.services.fields import (
94
89
    Description,
95
90
    IconImageUpload,
128
123
    """IDistribution properties requiring launchpad.Driver permission."""
129
124
 
130
125
    def newSeries(name, displayname, title, summary, description,
131
 
                  version, previous_series, registrant):
 
126
                  version, parent_series, registrant):
132
127
        """Creates a new distroseries."""
133
128
 
134
129
 
135
130
class IDistributionPublic(
136
131
    IBugTarget, ICanGetMilestonesDirectly, IHasAppointedDriver,
137
132
    IHasBuildRecords, IHasDrivers, IHasMilestones,
138
 
    IHasOOPSReferences, IHasOwner, IHasSecurityContact, IHasSprints,
139
 
    IHasTranslationImports, ITranslationPolicy, IKarmaContext,
140
 
    ILaunchpadUsage, IMakesAnnouncements, IOfficialBugTagTargetPublic,
141
 
    IPillar, IServiceUsage, ISpecificationTarget):
 
133
    IHasOwner, IHasSecurityContact, IHasSprints, IHasTranslationImports,
 
134
    ITranslationPolicy, IKarmaContext, ILaunchpadUsage, IMakesAnnouncements,
 
135
    IOfficialBugTagTargetPublic, IPillar, IServiceUsage,
 
136
    ISpecificationTarget):
142
137
    """Public IDistribution properties."""
143
138
 
144
139
    id = Attribute("The distro's unique number.")
161
156
        Summary(
162
157
            title=_("Summary"),
163
158
            description=_(
164
 
                "A short paragraph to introduce the goals and highlights "
 
159
                "A short paragraph to introduce the the goals and highlights "
165
160
                "of the distribution."),
166
161
            required=True))
167
162
    homepage_content = exported(
212
207
        exported_as='domain_name')
213
208
    owner = exported(
214
209
        PublicPersonChoice(
215
 
            title=_("Owner"),
216
 
            required=True,
217
 
            vocabulary='ValidPillarOwner',
218
 
            description=_("The restricted team, moderated team, or person "
219
 
                          "who maintains the distribution information in "
220
 
                          "Launchpad.")))
 
210
            title=_("Owner"), vocabulary='ValidOwner',
 
211
            description=_("The distro's owner."), required=True))
221
212
    registrant = exported(
222
213
        PublicPersonChoice(
223
214
            title=_("Registrant"), vocabulary='ValidPersonOrTeam',
287
278
    uploaders = Attribute(_(
288
279
        "ArchivePermission records for uploaders with rights to upload to "
289
280
        "this distribution."))
290
 
    package_derivatives_email = TextLine(
291
 
        title=_("Package Derivatives Email Address"),
292
 
        description=_(
293
 
            "The email address to send information about updates to packages "
294
 
            "that are derived from another distribution. The sequence "
295
 
            "{package_name} is replaced with the actual package name."),
296
 
        required=False)
297
281
 
298
282
    # properties
299
283
    currentseries = exported(
355
339
                      "on disk."),
356
340
        readonly=True, required=False)
357
341
 
358
 
    has_published_sources = Bool(
359
 
        title=_("Has Published Sources"),
360
 
        description=_("True if this distribution has sources published."),
361
 
        readonly=True, required=False)
362
 
 
363
342
    def getArchiveIDList(archive=None):
364
343
        """Return a list of archive IDs suitable for sqlvalues() or quote().
365
344
 
406
385
            `IDistroSeries.version`.
407
386
        """
408
387
 
409
 
    # This API is specifically for Ensemble's Principia.  It does not scale
410
 
    # well to distributions of Ubuntu's scale, and is not intended for it.
411
 
    # Therefore, this should probably never be exposed for a webservice
412
 
    # version other than "devel".
413
 
    @operation_parameters(
414
 
        since=Datetime(
415
 
            title=_("Time of last change"),
416
 
            description=_(
417
 
                "Return branches that have new tips since this timestamp."),
418
 
            required=False))
419
 
    @call_with(user=REQUEST_USER)
420
 
    @export_operation_as(name="getBranchTips")
421
 
    @export_read_operation()
422
 
    @operation_for_version('devel')
423
 
    def getBranchTips(user=None, since=None):
424
 
        """Return a list of branches which have new tips since a date.
425
 
 
426
 
        Each branch information is a tuple of (branch_unique_name,
427
 
        tip_revision, (official_series*)).
428
 
 
429
 
        So for each branch in the distribution, you'll get the branch unique
430
 
        name, the revision id of tip, and if the branch is official for some
431
 
        series, the list of series name.
432
 
 
433
 
        :param: user: If specified, shows the branches visible to that user.
434
 
            if not specified, only branches visible to the anonymous user are
435
 
            shown.
436
 
 
437
 
        :param since: If specified, limits results to branches modified since
438
 
            that date and time.
439
 
        """
440
 
 
441
388
    @operation_parameters(
442
389
        name=TextLine(title=_("Name"), required=True))
443
390
    @operation_returns_entry(IDistributionMirror)
503
450
        :return: list of `IDistroSeries`
504
451
        """
505
452
 
 
453
    def getSourcePackageCaches(archive=None):
 
454
        """The set of all source package info caches for this distribution.
 
455
 
 
456
        If 'archive' is not given it will return all caches stored for the
 
457
        distribution main archives (PRIMARY and PARTNER).
 
458
        """
 
459
 
 
460
    def removeOldCacheItems(archive, log):
 
461
        """Delete any cache records for removed packages.
 
462
 
 
463
        Also purges all existing cache records for disabled archives.
 
464
 
 
465
        :param archive: target `IArchive`.
 
466
        :param log: the context logger object able to print DEBUG level
 
467
            messages.
 
468
        """
 
469
 
 
470
    def updateCompleteSourcePackageCache(archive, log, ztm, commit_chunk=500):
 
471
        """Update the source package cache.
 
472
 
 
473
        Consider every non-REMOVED sourcepackage and entirely skips updates
 
474
        for disabled archives.
 
475
 
 
476
        :param archive: target `IArchive`;
 
477
        :param log: logger object for printing debug level information;
 
478
        :param ztm:  transaction used for partial commits, every chunk of
 
479
            'commit_chunk' updates is committed;
 
480
        :param commit_chunk: number of updates before commit, defaults to 500.
 
481
 
 
482
        :return the number packages updated done
 
483
        """
 
484
 
 
485
    def updateSourcePackageCache(sourcepackagename, archive, log):
 
486
        """Update cached source package details.
 
487
 
 
488
        Update cache details for a given ISourcePackageName, including
 
489
        generated binarypackage names, summary and description fti.
 
490
        'log' is required and only prints debug level information.
 
491
        """
 
492
 
506
493
    @rename_parameters_as(text="source_match")
507
494
    @operation_parameters(
508
495
        text=TextLine(title=_("Source package name substring match"),
550
537
        (a substring of) their binary package names.
551
538
        """
552
539
 
553
 
    def guessPublishedSourcePackageName(pkgname):
554
 
        """Return the "published" SourcePackageName related to pkgname.
555
 
 
556
 
        If pkgname corresponds to a source package that was published in
557
 
        any of the distribution series, that's the SourcePackageName that is
558
 
        returned.
559
 
 
560
 
        If there is any official source package branch linked, then that
561
 
        source package name is returned.
562
 
 
563
 
        Otherwise, try to find a published binary package name and then return
564
 
        the source package name from which it comes from.
565
 
 
566
 
        :raises NotFoundError: when pkgname doesn't correspond to either a
567
 
            published source or binary package name in this distribution.
 
540
    def searchBinaryPackagesFTI(package_name):
 
541
        """Do an FTI search on binary packages.
 
542
 
 
543
        :param package_name: The binary package name to search for.
 
544
        :return: A result set containing DistributionSourcePackageCache
 
545
            objects for the matching binaries found via an FTI search on
 
546
            DistroSeriesPackageCache.
 
547
        """
 
548
 
 
549
    def getFileByName(filename, archive=None, source=True, binary=True):
 
550
        """Find and return a LibraryFileAlias for the filename supplied.
 
551
 
 
552
        The file returned will be one of those published in the distribution.
 
553
 
 
554
        If searching both source and binary, and the file is found in the
 
555
        binary packages it'll return that over a file for a source package.
 
556
 
 
557
        If 'archive' is not passed the distribution.main_archive is assumed.
 
558
 
 
559
        At least one of source and binary must be true.
 
560
 
 
561
        Raises NotFoundError if it fails to find the named file.
 
562
        """
 
563
 
 
564
    def guessPackageNames(pkgname):
 
565
        """Try and locate source and binary package name objects that
 
566
        are related to the provided name --  which could be either a
 
567
        source or a binary package name. Returns a tuple of
 
568
        (sourcepackagename, binarypackagename) based on the current
 
569
        publishing status of these binary / source packages. Raises
 
570
        NotFoundError if it fails to find any package published with
 
571
        that name in the distribution.
568
572
        """
569
573
 
570
574
    def getAllPPAs():
637
641
 
638
642
class IDistribution(
639
643
    IDistributionEditRestricted, IDistributionPublic, IHasBugSupervisor,
640
 
    IQuestionTarget, IRootContext, IStructuralSubscriptionTarget):
 
644
    IRootContext, IStructuralSubscriptionTarget):
641
645
    """An operating system distribution.
642
646
 
643
647
    Launchpadlib example: retrieving the current version of a package in a
709
713
        :return: A dict as per `IDistribution.getCurrentSourceReleases`
710
714
        """
711
715
 
712
 
    def getDerivedDistributions():
713
 
        """Find derived distributions.
714
 
 
715
 
        :return: An iterable of all derived distributions (not including
716
 
            Ubuntu, even if it is technically derived from Debian).
717
 
        """
718
 
 
719
716
 
720
717
class NoSuchDistribution(NameLookupFailed):
721
718
    """Raised when we try to find a distribution that doesn't exist."""