本文整理匯總了Python中corehq.apps.receiverwrapper.models.CaseRepeater.get方法的典型用法代碼示例。如果您正苦於以下問題:Python CaseRepeater.get方法的具體用法?Python CaseRepeater.get怎麽用?Python CaseRepeater.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類corehq.apps.receiverwrapper.models.CaseRepeater
的用法示例。
在下文中一共展示了CaseRepeater.get方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: handle
# 需要導入模塊: from corehq.apps.receiverwrapper.models import CaseRepeater [as 別名]
# 或者: from corehq.apps.receiverwrapper.models.CaseRepeater import get [as 別名]
def handle(self, *args, **options):
domain = 'care-bihar'
# forward all cases that were last modified between these dates
def should_forward_case(case):
min_date = datetime(2013, 9, 10)
max_date = datetime(2013, 11, 7)
return (case.server_modified_on
and min_date < case.server_modified_on < max_date)
prod_repeater = CaseRepeater.get('a478a5a3d8964338cb3124de77e3ec58')
success_count = 0
fail_count = 0
for case in get_cases_in_domain(domain):
try:
if should_forward_case(case):
prod_repeater.register(case)
success_count += 1
except Exception:
fail_count += 1
logging.exception('problem creating repeater stub for case %s' % case._id)
print 'successfully forwarded %s cases. %s were not processed' % (success_count, fail_count)