本文整理汇总了Python中lp.services.database.interfaces.IStore.count方法的典型用法代码示例。如果您正苦于以下问题:Python IStore.count方法的具体用法?Python IStore.count怎么用?Python IStore.count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lp.services.database.interfaces.IStore
的用法示例。
在下文中一共展示了IStore.count方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _update
# 需要导入模块: from lp.services.database.interfaces import IStore [as 别名]
# 或者: from lp.services.database.interfaces.IStore import count [as 别名]
def _update(cls, distroseries, binarypackagename, archive, log):
"""Update the package cache for a given IBinaryPackageName
'log' is required, it should be a logger object able to print
DEBUG level messages.
'ztm' is the current trasaction manager used for partial commits
(in full batches of 100 elements)
"""
# get the set of published binarypackagereleases
bprs = IStore(BinaryPackageRelease).find(
BinaryPackageRelease,
BinaryPackageRelease.id ==
BinaryPackagePublishingHistory.binarypackagereleaseID,
BinaryPackagePublishingHistory.binarypackagename ==
binarypackagename,
BinaryPackagePublishingHistory.distroarchseriesID ==
DistroArchSeries.id,
DistroArchSeries.distroseries == distroseries,
BinaryPackagePublishingHistory.archive == archive,
BinaryPackagePublishingHistory.dateremoved == None)
bprs = bprs.order_by(Desc(BinaryPackageRelease.datecreated))
bprs = bprs.config(distinct=True)
if bprs.count() == 0:
log.debug("No binary releases found.")
return
# find or create the cache entry
cache = cls.selectOne("""
distroseries = %s AND
archive = %s AND
binarypackagename = %s
""" % sqlvalues(distroseries, archive, binarypackagename))
if cache is None:
log.debug("Creating new binary cache entry.")
cache = cls(
archive=archive,
distroseries=distroseries,
binarypackagename=binarypackagename)
# make sure the cached name, summary and description are correct
cache.name = binarypackagename.name
cache.summary = bprs[0].summary
cache.description = bprs[0].description
# get the sets of binary package summaries, descriptions. there is
# likely only one, but just in case...
summaries = set()
descriptions = set()
for bpr in bprs:
log.debug("Considering binary version %s" % bpr.version)
summaries.add(bpr.summary)
descriptions.add(bpr.description)
# and update the caches
cache.summaries = ' '.join(sorted(summaries))
cache.descriptions = ' '.join(sorted(descriptions))
示例2: test_initially_empty
# 需要导入模块: from lp.services.database.interfaces import IStore [as 别名]
# 或者: from lp.services.database.interfaces.IStore import count [as 别名]
def test_initially_empty(self):
# A test just to confirm that the RevisionCache is empty.
results = IStore(RevisionCache).find(RevisionCache)
self.assertEqual(0, results.count())