Add cache_model()
convenience method for problem reports
This commit is contained in:
parent
3d85857ea1
commit
06ea22ae58
|
@ -2,7 +2,7 @@
|
|||
################################################################################
|
||||
#
|
||||
# Rattail -- Retail Software Framework
|
||||
# Copyright © 2010-2019 Lance Edgar
|
||||
# Copyright © 2010-2020 Lance Edgar
|
||||
#
|
||||
# This file is part of Rattail.
|
||||
#
|
||||
|
@ -27,6 +27,7 @@ Problem Reports Framework
|
|||
from __future__ import unicode_literals, absolute_import
|
||||
|
||||
from rattail.util import progress_loop
|
||||
from rattail.db import cache
|
||||
|
||||
|
||||
class ProblemReport(object):
|
||||
|
@ -53,6 +54,16 @@ class ProblemReport(object):
|
|||
factory = factory or self.progress
|
||||
return progress_loop(func, items, factory, **kwargs)
|
||||
|
||||
def cache_model(self, session, model, **kwargs):
|
||||
"""
|
||||
Convenience method which invokes
|
||||
:func:`~rattail.db.cache.cache_model()` with the given model and
|
||||
keyword arguments. This method will provide the ``progress`` parameter
|
||||
by default.
|
||||
"""
|
||||
kwargs.setdefault('progress', self.progress)
|
||||
return cache.cache_model(session, model, **kwargs)
|
||||
|
||||
def find_problems(self, **kwargs):
|
||||
"""
|
||||
Find all problems for which this report is responsible. This should
|
||||
|
|
Loading…
Reference in a new issue