Merge ~cjwatson/launchpad:fix-translation-sharing-job-derived into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 0db013efabae44f13d219e69bc74f025bd82c9ed
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:fix-translation-sharing-job-derived
Merge into: launchpad:master
Diff against target: 45 lines (+7/-2)
2 files modified
lib/lp/translations/interfaces/translationsharingjob.py (+5/-0)
lib/lp/translations/model/translationsharingjob.py (+2/-2)
Reviewer Review Type Date Requested Status
Tom Wardill (community) Approve
Review via email: mp+382817@code.launchpad.net

Commit message

Regularise TranslationSharingJobDerived slightly

Description of the change

This makes it a little more like other job classes, and in particular arranges that .job.id on its subclasses that implement IRunnableJob will refer to the ID of a Job table and not something else.

I ran into trouble with the slightly dodgy old approach while trying to fix BaseRunnableJob to work with transaction 3.0.0.

To post a comment you must log in.
Revision history for this message
Tom Wardill (twom) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/translations/interfaces/translationsharingjob.py b/lib/lp/translations/interfaces/translationsharingjob.py
2index 7989eb6..82478d6 100644
3--- a/lib/lp/translations/interfaces/translationsharingjob.py
4+++ b/lib/lp/translations/interfaces/translationsharingjob.py
5@@ -3,6 +3,7 @@
6
7 __metaclass__ = type
8
9+from lazr.restful.fields import Reference
10 from zope.interface import Attribute
11
12 from lp import _
13@@ -11,6 +12,10 @@ from lp.services.job.interfaces.job import IJob
14
15 class ITranslationSharingJob(IJob):
16
17+ job = Reference(
18+ title=_("The common Job attributes."), schema=IJob,
19+ required=True, readonly=True)
20+
21 productseries = Attribute(_("The productseries of the Packaging."))
22
23 distroseries = Attribute(_("The distroseries of the Packaging."))
24diff --git a/lib/lp/translations/model/translationsharingjob.py b/lib/lp/translations/model/translationsharingjob.py
25index e09a95e..80cdad4 100644
26--- a/lib/lp/translations/model/translationsharingjob.py
27+++ b/lib/lp/translations/model/translationsharingjob.py
28@@ -113,7 +113,7 @@ class TranslationSharingJob(StormBase):
29 return TranslationSharingJobDerived.makeSubclass(self)
30
31
32-@delegate_to(ITranslationSharingJob, context='job')
33+@delegate_to(ITranslationSharingJob)
34 class TranslationSharingJobDerived:
35 """Base class for specialized TranslationTemplate Job types."""
36
37@@ -143,7 +143,7 @@ class TranslationSharingJobDerived:
38 assert job.job_type == self.class_job_type, (
39 "Attempting to create a %s using a %s TranslationSharingJob" %
40 (self.__class__.__name__, job.job_type))
41- self.job = job
42+ self.context = job
43
44 @classmethod
45 def create(cls, productseries=None, distroseries=None,

Subscribers

People subscribed via source and target branches

to status/vote changes: