~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/code/model/sourcepackagerecipebuild.py

  • Committer: Raphael Badin
  • Date: 2012-01-04 16:56:17 UTC
  • mfrom: (14513.5.1 builder-history-lfa)
  • mto: This revision was merged to the branch mainline in revision 14654.
  • Revision ID: raphael.badin@canonical.com-20120104165617-jcbzne6htiivfz99
Merge.

Show diffs side-by-side

added added

removed removed

Lines of Context:
69
69
    )
70
70
from lp.services.job.model.job import Job
71
71
from lp.services.librarian.browser import ProxiedLibraryFileAlias
72
 
from lp.services.propertycache import (
73
 
    cachedproperty,
74
 
    get_property_cache,
75
 
    )
76
72
from lp.soyuz.interfaces.archive import CannotUploadToArchive
77
73
from lp.soyuz.model.archive import Archive
78
74
from lp.soyuz.model.binarypackagebuild import BinaryPackageBuild
156
152
    requester_id = Int(name='requester', allow_none=False)
157
153
    requester = Reference(requester_id, 'Person.id')
158
154
 
159
 
    @cachedproperty
160
155
    def buildqueue_record(self):
161
156
        """See `IBuildFarmJob`."""
162
157
        store = Store.of(self)
166
161
            SourcePackageRecipeBuildJob.build == self.id)
167
162
        return results.one()
168
163
 
169
 
    @staticmethod
170
 
    def prefetchBuildqueueRecord(sourcepackagerecipebuilds):
171
 
        ids = [sprb.id for sprb in sourcepackagerecipebuilds]
172
 
        store = IStore(SourcePackageRecipeBuildJob)
173
 
        results = store.find(
174
 
            (SourcePackageRecipeBuildJob, BuildQueue),
175
 
            SourcePackageRecipeBuildJob.job == BuildQueue.jobID,
176
 
            SourcePackageRecipeBuildJob.build_id.is_in(ids))
177
 
        sprb_dict = dict(
178
 
            (result[0].build.id, result[1]) for result in results)
179
 
        for sprb in sourcepackagerecipebuilds:
180
 
            cache = get_property_cache(sprb)
181
 
            cache.buildqueue_record = sprb_dict.get(sprb.id, None)
182
 
 
183
164
    @property
184
165
    def source_package_release(self):
185
166
        """See `ISourcePackageRecipeBuild`."""
310
291
        from lp.code.model.sourcepackagerecipe import SourcePackageRecipe
311
292
        from lp.services.librarian.model import LibraryFileAlias
312
293
        from lp.buildmaster.model.buildfarmjob import BuildFarmJob
313
 
        SourcePackageRecipeBuild.prefetchBuildqueueRecord(builds)
314
294
        package_builds = load_related(
315
295
            PackageBuild, builds, ['package_build_id'])
316
296
        build_farm_jobs = load_related(