~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/soyuz/model/sourcepackagebuild.py

  • Committer: Jonathan Lange
  • Date: 2010-01-12 02:42:49 UTC
  • mto: (10130.7.3 builder-behavior)
  • mto: This revision was merged to the branch mainline in revision 10225.
  • Revision ID: jml@canonical.com-20100112024249-sc79o87i1w3s3heu
Actually make the build object work.

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
    'SourcePackageBuild',
9
9
    ]
10
10
 
11
 
 
 
11
from canonical.database.constants import UTC_NOW
12
12
from canonical.database.datetimecol import UtcDateTimeCol
13
13
from canonical.database.enumcol import EnumCol
14
14
from canonical.launchpad.interfaces.lpstorm import IMasterStore
40
40
    build_log = Reference(build_log_id, 'LibraryFileAlias.id')
41
41
 
42
42
    build_state = EnumCol(
43
 
        dbName='buildstate', notNull=True, schema=BuildStatus)
 
43
        dbName='build_state', notNull=True, schema=BuildStatus)
44
44
 
45
45
    date_created = UtcDateTimeCol(notNull=True)
46
 
    date_built = UtcDateTimeCol(notNull=True)
47
 
    date_first_dispatched = UtcDateTimeCol(notNull=True)
 
46
    date_built = UtcDateTimeCol(notNull=False)
 
47
    date_first_dispatched = UtcDateTimeCol(notNull=False)
48
48
 
49
49
    distroseries_id = Int(name='distroseries', allow_none=True)
50
50
    distroseries = Reference(distroseries_id, 'DistroSeries.id')
55
55
    recipe_id = Int(name='recipe', allow_none=False)
56
56
    recipe = Reference(recipe_id, 'SourcePackageRecipe.id')
57
57
 
58
 
    requester_id = Int(name='requester', allow_none=True)
 
58
    requester_id = Int(name='requester', allow_none=False)
59
59
    requester = Reference(requester_id, 'Person.id')
60
60
 
61
61
    manifest_id = Int(name='manifest', allow_none=True)
62
62
    manifest = Reference(manifest_id, '_SourcePackageRecipeData.id')
63
63
 
 
64
    def __init__(self, distroseries, sourcepackagename, recipe, requester,
 
65
                 date_created=None, date_first_dispatched=None,
 
66
                 date_built=None, manifest=None, builder=None,
 
67
                 build_state=BuildStatus.NEEDSBUILD, build_log=None,
 
68
                 build_duration=None):
 
69
        """Construct a SourcePackageBuild."""
 
70
        super(SourcePackageBuild, self).__init__()
 
71
        self.build_duration = build_duration
 
72
        self.build_log = build_log
 
73
        self.builder = builder
 
74
        self.build_state = build_state
 
75
        self.date_built = date_built
 
76
        self.date_created = date_created
 
77
        self.date_first_dispatched = date_first_dispatched
 
78
        self.distroseries = distroseries
 
79
        self.manifest = manifest
 
80
        self.recipe = recipe
 
81
        self.requester = requester
 
82
        self.sourcepackagename = sourcepackagename
 
83
 
64
84
    @classmethod
65
 
    def new(cls):
 
85
    def new(cls, sourcepackage, recipe, requester, date_created=None):
 
86
        """See `ISourcePackageBuildSource`."""
66
87
        store = IMasterStore(SourcePackageBuild)
67
 
        spbuild = cls()
 
88
        if date_created is None:
 
89
            date_created = UTC_NOW
 
90
        spbuild = cls(
 
91
            sourcepackage.distroseries,
 
92
            sourcepackage.sourcepackagename,
 
93
            recipe,
 
94
            requester,
 
95
            date_created=date_created)
68
96
        store.add(spbuild)
69
97
        return spbuild