l.s.d.d.DecoratedResultSet(object) : class documentation

Part of lp.services.database.decoratedresultset View In Hierarchy

A decorated Storm ResultSet for 'Magic' (presenter) classes.

Because DistroSeriesBinaryPackage doesn't actually exist in the database, the DistroSeries.searchPackages method uses the DistroSeriesPackageCache object to search for packages within a DistroSeries.

Nonetheless, the users of the searchPackages method (such as the DistroSeriesView) expect a result set of DSBPs. Rather than executing the query prematurely and doing a list comprehension on the complete result set (which could be very large) to convert all the results (even though batching may mean only a window of 10 results is required), this adapted result set converts the results only when they are needed.

This behaviour is required for other classes as well (Distribution, DistroArchSeries), hence a generalised solution.

Method __init__ Wrap result_set in a decorator.
Method decorate_single Decorate a result or return None if the result is itself None
Method copy See IResultSet.
Method config See IResultSet.
Method __iter__ See IResultSet.
Method __getitem__ See IResultSet.
Method iterhook_one_elem Undocumented
Method any See IResultSet.
Method first See IResultSet.
Method last See IResultSet.
Method one See IResultSet.
Method order_by See IResultSet.
Method get_plain_result_set Return the plain Storm result set.
Method find See IResultSet.
Method _extract_plain_and_result Extract the plain and normal results from a sub-result.
def __init__(self, result_set, result_decorator=None, pre_iter_hook=None, bulk_decorator=None, slice_info=False, return_both=False):
Wrap result_set in a decorator.

The decorator will act as a result set where a result row self[x] is really result_decorator(result_set[x]).

Parametersresult_setThe original result set to be decorated.
result_decoratorA transformation function that individual results will be passed through. Mutually exclusive with bulk_decorator.
pre_iter_hookThe method to be called (with the 'result_set') immediately before iteration starts. The return value of the hook is ignored.
bulk_decoratorA transformation function that chunks of results will be passed through. Mutually exclusive with result_decorator.
slice_infoIf True pass information about the slice parameters to the result_decorator and pre_iter_hook. any() and similar methods will cause None to be supplied.
return_bothIf True return both the plain and decorated values as a tuple.
def _extract_plain_and_result(self, results):
Extract the plain and normal results from a sub-result.

This gets slightly complicated when there are nested DecoratedResultSets, as we have to propogate the plain result all the way up.

def decorate_single(self, result, row_index=None):
Decorate a result or return None if the result is itself None
def copy(self, *args, **kwargs):
See IResultSet.
ReturnsThe decorated version of the returned result set.
def config(self, *args, **kwargs):
See IResultSet.
ReturnsThe decorated result set.after updating the config.
def __iter__(self, *args, **kwargs):
See IResultSet.

Yield a decorated version of the returned value.

def __getitem__(self, *args, **kwargs):
See IResultSet.
ReturnsThe decorated version of the returned value.
def iterhook_one_elem(self, value):
Undocumented
def any(self, *args, **kwargs):
See IResultSet.
ReturnsThe decorated version of the returned value.
def first(self, *args, **kwargs):
See IResultSet.
ReturnsThe decorated version of the returned value.
def last(self, *args, **kwargs):
See IResultSet.
ReturnsThe decorated version of the returned value.
def one(self, *args, **kwargs):
See IResultSet.
ReturnsThe decorated version of the returned value.
def order_by(self, *args, **kwargs):
See IResultSet.
ReturnsThe decorated version of the returned result set.
def get_plain_result_set(self):
Return the plain Storm result set.
def find(self, *args, **kwargs):
See IResultSet.
ReturnsThe decorated version of the returned result set.
API Documentation for Launchpad, generated by pydoctor at 2022-06-16 00:00:12.