~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/registry/interfaces/distroseriesdifference.py

  • Committer: Gavin Panella
  • Date: 2011-06-01 09:02:19 UTC
  • mto: This revision was merged to the branch mainline in revision 13150.
  • Revision ID: gavin.panella@canonical.com-20110601090219-q30fhh4jdh72kmk9
Link sourcecode in parallel. On a 4-core machine this cuts the time taken by about 70%.

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
 
9
9
__all__ = [
10
10
    'IDistroSeriesDifference',
11
 
    'IDistroSeriesDifferenceAdmin',
12
11
    'IDistroSeriesDifferencePublic',
13
12
    'IDistroSeriesDifferenceEdit',
14
13
    'IDistroSeriesDifferenceSource',
23
22
    REQUEST_USER,
24
23
    )
25
24
from lazr.restful.fields import Reference
26
 
from zope.interface import (
27
 
    Attribute,
28
 
    Interface,
29
 
    )
 
25
from zope.interface import Interface
30
26
from zope.schema import (
31
27
    Bool,
32
28
    Choice,
59
55
    derived_series = exported(Reference(
60
56
        IDistroSeries, title=_("Derived series"), required=True,
61
57
        readonly=True, description=_(
62
 
            "The distribution series which identifies the derived series "
63
 
            "with the difference.")))
64
 
 
65
 
    parent_series = exported(Reference(
66
 
        IDistroSeries, title=_("Parent series"), required=True,
67
 
        readonly=True, description=_(
68
 
            "The distribution series which identifies the parent series "
69
 
            "with the difference.")))
70
 
 
71
 
    source_package_name_id = Int(
72
 
        title=u"Source package name id", required=True, readonly=True)
 
58
            "The distribution series which, together with its parent, "
 
59
            "identifies the two series with the difference.")))
 
60
 
73
61
    source_package_name = Reference(
74
62
        ISourcePackageName,
75
63
        title=_("Source package name"), required=True, readonly=True,
189
177
        title=_("Title"), readonly=True, required=False, description=_(
190
178
            "A human-readable name describing this difference."))
191
179
 
192
 
    packagesets = Attribute("The packagesets for this source package in the "
193
 
                            "derived series.")
194
 
 
195
 
    parent_packagesets = Attribute("The packagesets for this source package "
196
 
                                   "in the parent series.")
197
 
 
198
 
    def update(manual=False):
 
180
    def update():
199
181
        """Checks that difference type and status matches current publishings.
200
182
 
201
183
        If the record is updated, a relevant comment is added.
203
185
        If there is no longer a difference (ie. the versions are
204
186
        the same) then the status is updated to RESOLVED.
205
187
 
206
 
        :param manual: Boolean, True if this is a user-requested change.
207
 
            This overrides auto-blacklisting.
208
188
        :return: True if the record was updated, False otherwise.
209
189
        """
210
190
 
211
191
    latest_comment = Reference(
212
 
        Interface,  # IDistroSeriesDifferenceComment
 
192
        Interface, # IDistroSeriesDifferenceComment
213
193
        title=_("The latest comment"),
214
194
        readonly=True)
215
195
 
216
196
    def getComments():
217
197
        """Return a result set of the comments for this difference."""
218
198
 
 
199
    def getPackageSets():
 
200
        """Return a result set of the derived series packagesets for the
 
201
        sourcepackagename of this difference.
 
202
        """
 
203
 
 
204
    def getParentPackageSets():
 
205
        """Return a result set of the parent packagesets for the
 
206
        sourcepackagename of this difference.
 
207
        """
 
208
 
219
209
 
220
210
class IDistroSeriesDifferenceEdit(Interface):
221
211
    """Difference attributes requiring launchpad.Edit."""
227
217
    def addComment(commenter, comment):
228
218
        """Add a comment on this difference."""
229
219
 
230
 
    @call_with(requestor=REQUEST_USER)
231
 
    @export_write_operation()
232
 
    def requestPackageDiffs(requestor):
233
 
        """Requests IPackageDiffs for the derived and parent version.
234
 
 
235
 
        :raises DistroSeriesDifferenceError: When package diffs
236
 
            cannot be requested.
237
 
        """
238
 
 
239
 
 
240
 
class IDistroSeriesDifferenceAdmin(Interface):
241
 
    """Difference attributes requiring launchpad.Admin."""
242
 
 
243
220
    @operation_parameters(
244
221
        all=Bool(title=_("All"), required=False))
245
222
    @export_write_operation()
257
234
        The status will be updated based on the versions.
258
235
        """
259
236
 
 
237
    @call_with(requestor=REQUEST_USER)
 
238
    @export_write_operation()
 
239
    def requestPackageDiffs(requestor):
 
240
        """Requests IPackageDiffs for the derived and parent version.
 
241
 
 
242
        :raises DistroSeriesDifferenceError: When package diffs
 
243
            cannot be requested.
 
244
        """
 
245
 
260
246
 
261
247
class IDistroSeriesDifference(IDistroSeriesDifferencePublic,
262
 
                              IDistroSeriesDifferenceEdit,
263
 
                              IDistroSeriesDifferenceAdmin):
 
248
                              IDistroSeriesDifferenceEdit):
264
249
    """An interface for a package difference between two distroseries."""
265
250
    export_as_webservice_entry()
266
251
 
268
253
class IDistroSeriesDifferenceSource(Interface):
269
254
    """A utility of this interface can be used to create differences."""
270
255
 
271
 
    def new(derived_series, source_package_name, parent_series=None):
 
256
    def new(derived_series, source_package_name):
272
257
        """Create an `IDistroSeriesDifference`.
273
258
 
274
259
        :param derived_series: The distribution series which was derived
278
263
        :param source_package_name: A source package name identifying the
279
264
            package with a difference.
280
265
        :type source_package_name: `ISourcePackageName`.
281
 
        :param parent_series: The distribution series which has the derived
282
 
            series as a child. If there is only one parent, it does not need
283
 
            to be specified.
284
 
        :type parent_series: `IDistroSeries`.
285
266
        :raises NotADerivedSeriesError: When the passed distro series
286
267
            is not a derived series.
287
268
        :return: A new `DistroSeriesDifference` object.
289
270
 
290
271
    def getForDistroSeries(
291
272
        distro_series,
292
 
        difference_type=None,
 
273
        difference_type=DistroSeriesDifferenceType.DIFFERENT_VERSIONS,
293
274
        source_package_name_filter=None,
294
275
        status=None,
295
 
        child_version_higher=False,
296
 
        parent_series=None):
 
276
        child_version_higher=False):
297
277
        """Return differences for the derived distro series sorted by
298
278
        package name.
299
279
 
303
283
        :param difference_type: The type of difference to include in the
304
284
            results.
305
285
        :type difference_type: `DistroSeriesDifferenceType`.
306
 
        :param source_package_name_filter: Name of a source package.  If
307
 
            given, restricts the search to this package.
 
286
        :param source_package_name_filter: Package source name filter.
308
287
        :type source_package_name_filter: unicode.
309
288
        :param status: Only differences matching the status(es) will be
310
289
            included.
312
291
        :param child_version_higher: Only differences for which the child's
313
292
            version is higher than the parent's version will be included.
314
293
        :type child_version_higher: bool.
315
 
        :param parent_series: The parent series to consider. Consider all
316
 
            parent series if this parameter is None.
317
 
        :type distro_series: `IDistroSeries`.
318
 
        :return: A result set of `IDistroSeriesDifference`.
 
294
        :return: A result set of differences.
319
295
        """
320
296
 
321
 
    def getByDistroSeriesNameAndParentSeries(distro_series,
322
 
                                             source_package_name,
323
 
                                             parent_series):
324
 
        """Returns a single difference matching the series, name and parent
325
 
        series.
 
297
    def getByDistroSeriesAndName(distro_series, source_package_name):
 
298
        """Returns a single difference matching the series and name.
326
299
 
327
300
        :param distro_series: The derived distribution series which is to be
328
301
            searched for differences.
329
302
        :type distro_series: `IDistroSeries`.
330
303
        :param source_package_name: The name of the package difference.
331
304
        :type source_package_name: unicode.
332
 
        :param parent_series: The parent distribution series of the package
333
 
        difference.
334
 
        :type distro_series: `IDistroSeries`.
335
 
        """
336
 
 
337
 
    def getSimpleUpgrades(distro_series):
338
 
        """Find pending upgrades that can be performed mindlessly.
339
 
 
340
 
        These are `DistroSeriesDifferences` where the parent has been
341
 
        updated and the child still has the old version, unchanged.
342
 
 
343
 
        Blacklisted items are excluded.
344
305
        """