l.c.b.d.DecoratedBranch(BzrIdentityMixin) : class documentation

Part of lp.code.browser.decorations View In Hierarchy

Wrap a number of the branch accessors to cache results.

This avoids repeated db queries.

Method __init__ Undocumented
Method displayname Override the default model property.
Method bzr_identity Cache the result of the bzr identity.
Method is_series_branch A simple property to see if there are any series links.
Method associatedProductSeries Override the IBranch.associatedProductSeries.
Method associatedSuiteSourcePackages Override the IBranch.associatedSuiteSourcePackages.
Method associated_product_series Cache the realized product series links.
Method suite_source_packages Cache the realized suite source package links.
Method upgrade_pending Cache the result as the property hits the database.
Method subscriptions Cache the realized branch subscription objects.
Method hasSubscription Override the default branch implementation.
Method latest_revisions Cache the query result.

Inherited from BzrIdentityMixin:

Method shortened_path See IBranch.
Method getBranchIdentities See IBranch.
Method getBranchLinks See IBranch.
def __init__(self, branch):
Undocumented
@property
def displayname(self):
Override the default model property.

If left to the underlying model, it would call the bzr_identity on the underlying branch rather than the cached bzr_identity on the decorated branch. And that would cause two database queries.

@cachedproperty
def bzr_identity(self):
Cache the result of the bzr identity.

The property is defined in the bzrIdentityMixin class. This uses the associatedProductSeries and associatedSuiteSourcePackages methods.

@cachedproperty
def is_series_branch(self):
A simple property to see if there are any series links.
def associatedProductSeries(self):
Override the IBranch.associatedProductSeries.
def associatedSuiteSourcePackages(self):
Override the IBranch.associatedSuiteSourcePackages.
@cachedproperty
def associated_product_series(self):
Cache the realized product series links.
@cachedproperty
def suite_source_packages(self):
Cache the realized suite source package links.
@cachedproperty
def upgrade_pending(self):
Cache the result as the property hits the database.
@cachedproperty
def subscriptions(self):
Cache the realized branch subscription objects.
def hasSubscription(self, user):
Override the default branch implementation.

The default implementation hits the database. Since we have a full list of subscribers anyway, a simple check over the list is sufficient.

@cachedproperty
def latest_revisions(self):
Cache the query result.

When a tal:repeat is used, the method is called twice. Firstly to check that there is something to iterate over, and secondly for the actual iteration. Without the cached property, the database is hit twice.

API Documentation for Launchpad, generated by pydoctor at 2022-06-16 00:00:12.