~launchpad-pqm/launchpad/devel

« back to all changes in this revision

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

  • Committer: Steve Kowalik
  • Date: 2011-08-07 04:05:52 UTC
  • mto: This revision was merged to the branch mainline in revision 13626.
  • Revision ID: stevenk@ubuntu.com-20110807040552-mwnxo0flmhvl35e8
Correct the notification based on review comments, and remove request{,ed}
from the function names, switching to create{,d}.

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-2010 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=F0401,W1001
39
39
    implements,
40
40
    )
41
41
 
 
42
from canonical.database.constants import (
 
43
    DEFAULT,
 
44
    UTC_NOW,
 
45
    )
 
46
from canonical.database.datetimecol import UtcDateTimeCol
 
47
from canonical.launchpad.interfaces.lpstorm import (
 
48
    IMasterStore,
 
49
    IStore,
 
50
    )
42
51
from lp.app.interfaces.launchpad import ILaunchpadCelebrities
43
52
from lp.buildmaster.enums import BuildStatus
44
53
from lp.buildmaster.model.buildfarmjob import BuildFarmJob
56
65
from lp.code.interfaces.sourcepackagerecipebuild import (
57
66
    ISourcePackageRecipeBuildSource,
58
67
    )
59
 
from lp.code.model.branch import Branch
60
68
from lp.code.model.sourcepackagerecipebuild import SourcePackageRecipeBuild
61
69
from lp.code.model.sourcepackagerecipedata import SourcePackageRecipeData
62
70
from lp.registry.interfaces.distroseries import IDistroSeriesSet
63
71
from lp.registry.interfaces.pocket import PackagePublishingPocket
64
72
from lp.registry.model.distroseries import DistroSeries
65
 
from lp.services.database.bulk import (
66
 
    load_referencing,
67
 
    load_related,
68
 
    )
69
 
from lp.services.database.constants import (
70
 
    DEFAULT,
71
 
    UTC_NOW,
72
 
    )
73
 
from lp.services.database.datetimecol import UtcDateTimeCol
74
 
from lp.services.database.lpstorm import (
75
 
    IMasterStore,
76
 
    IStore,
77
 
    )
78
73
from lp.services.database.stormexpr import Greatest
79
 
from lp.services.propertycache import (
80
 
    cachedproperty,
81
 
    get_property_cache,
82
 
    )
83
74
from lp.soyuz.interfaces.archive import IArchiveSet
84
75
from lp.soyuz.model.archive import Archive
85
76
 
167
158
    name = Unicode(allow_none=True)
168
159
    description = Unicode(allow_none=True)
169
160
 
170
 
    @cachedproperty
 
161
    @property
171
162
    def _recipe_data(self):
172
163
        return Store.of(self).find(
173
164
            SourcePackageRecipeData,
182
173
    def base_branch(self):
183
174
        return self._recipe_data.base_branch
184
175
 
185
 
    @staticmethod
186
 
    def preLoadDataForSourcePackageRecipes(sourcepackagerecipes):
187
 
        # Load the referencing SourcePackageRecipeData.
188
 
        spr_datas = load_referencing(
189
 
            SourcePackageRecipeData,
190
 
            sourcepackagerecipes, ['sourcepackage_recipe_id'])
191
 
        # Load the related branches.
192
 
        load_related(Branch, spr_datas, ['base_branch_id'])
193
 
        # Store the SourcePackageRecipeData in the sourcepackagerecipes
194
 
        # objects.
195
 
        for spr_data in spr_datas:
196
 
            cache = get_property_cache(spr_data.sourcepackage_recipe)
197
 
            cache._recipe_data = spr_data
198
 
        SourcePackageRecipeData.preLoadReferencedBranches(spr_datas)
199
 
 
200
176
    def setRecipeText(self, recipe_text):
201
177
        parsed = SourcePackageRecipeData.getParsedRecipe(recipe_text)
202
178
        self._recipe_data.setRecipe(parsed)