l.s.w.v.CountableIterator : class documentation

Part of lp.services.webapp.vocabulary View In Hierarchy

Known subclasses: lp.services.webapp.vocabulary.BatchedCountableIterator

Implements a wrapping iterator with a count() method.

This iterator implements a subset of the ISelectResults interface; namely the portion required to have it work as part of a BatchNavigator.

Method __init__ Construct a CountableIterator instance.
Method count Return the number of items in the iterator.
Method __iter__ Iterate over my items.
Method __getitem__ Return a slice or item of my collection.
Method __len__ Undocumented
def __init__(self, count, iterator, item_wrapper=None):

Construct a CountableIterator instance.

Arguments:
  • count: number of items in the iterator
  • iterator: the iterable we wrap; normally a ISelectResults
  • item_wrapper: a callable that will be invoked for each item we return.
def count(self):
Return the number of items in the iterator.
def __iter__(self):
Iterate over my items.

This is used when building the <select> menu of options that is generated when we post a form.

def __getitem__(self, arg):
Return a slice or item of my collection.

This is used by BatchNavigator when it slices into us; we just pass on the buck down to our _iterator.

def __len__(self):
Undocumented
API Documentation for Launchpad, generated by pydoctor at 2022-06-16 00:00:12.