~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/registry/model/packagingjob.py

  • Committer: William Grant
  • Date: 2011-07-18 20:46:27 UTC
  • mto: This revision was merged to the branch mainline in revision 13465.
  • Revision ID: william.grant@canonical.com-20110718204627-s9nc1jv3r0vsl6ix
Revert r13420 (the relanding of r13292, which broke production in similar ways).

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
    JobStatus,
36
36
    )
37
37
from lp.services.job.model.job import Job
38
 
from lp.services.utils import RegisteredSubclass
39
38
 
40
39
 
41
40
class PackagingJobType(DBEnumeratedType):
97
96
        self.productseries = productseries
98
97
 
99
98
 
 
99
class RegisteredSubclass(type):
 
100
    """Metaclass for when subclasses should be registered."""
 
101
 
 
102
    def __init__(cls, name, bases, dict_):
 
103
        cls._register_subclass(cls)
 
104
 
 
105
 
100
106
class PackagingJobDerived:
101
107
    """Base class for specialized Packaging Job types."""
102
108
 
114
120
    @staticmethod
115
121
    def _register_subclass(cls):
116
122
        """Register this class with its enumeration."""
117
 
        # Why not a classmethod?  See RegisteredSubclass.__init__.
 
123
        # This would be a classmethod, except that subclasses (e.g.
 
124
        # TranslationPackagingJob) need to be able to override it and call
 
125
        # into it, and there's no syntax to call a base class's version of a
 
126
        # classmethod with the subclass as the first parameter.
118
127
        job_type = getattr(cls, 'class_job_type', None)
119
128
        if job_type is not None:
120
129
            value = cls._subclass.setdefault(job_type, cls)