本文整理汇总了Python中corehq.apps.app_manager.xpath.XPath.count方法的典型用法代码示例。如果您正苦于以下问题:Python XPath.count方法的具体用法?Python XPath.count怎么用?Python XPath.count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类corehq.apps.app_manager.xpath.XPath
的用法示例。
在下文中一共展示了XPath.count方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_module_contributions
# 需要导入模块: from corehq.apps.app_manager.xpath import XPath [as 别名]
# 或者: from corehq.apps.app_manager.xpath.XPath import count [as 别名]
def get_module_contributions(self, module):
if module_offers_search(module):
domain = self.app.domain
details_helper = DetailsHelper(self.app)
sync_request = SyncRequest(
post=SyncRequestPost(
url=absolute_reverse('claim_case', args=[domain]),
# Check whether the case to be claimed already exists in casedb:
# count(
# instance('casedb')/casedb/case[@case_id=instance('querysession')/session/data/case_id]
# ) = 0
relevant=XPath.count(
CaseIDXPath(QuerySessionXPath('case_id').instance()).case()
) + ' = 0',
data=[
QueryData(
key='case_id',
ref=QuerySessionXPath('case_id').instance(),
# e.g. instance('querysession')/session/data/case_id
),
]
),
command=Command(
id=id_strings.search_command(module),
display=Display(
text=Text(locale_id=id_strings.case_search_locale(module)),
),
),
instances=[Instance(
id=SESSION_INSTANCE,
src='jr://instance/session'
)],
session=SyncRequestSession(
queries=[
SyncRequestQuery(
url=absolute_reverse('sync_search', args=[domain]),
storage_instance=RESULTS_INSTANCE,
data=[
QueryData(
key='case_type',
ref="'{}'".format(module.case_type)
),
],
prompts=[
QueryPrompt(
key=p.name,
display=Display(
text=Text(locale_id=id_strings.search_property_locale(module, p.name)),
),
) for p in module.search_config.properties
]
)
],
data=[SessionDatum(
id='case_id',
nodeset=(CaseTypeXpath(module.case_type)
.case(instance_name=RESULTS_INSTANCE)
.select(u'@status', u'open', quote=True)),
value='./@case_id',
detail_select=details_helper.get_detail_id_safe(module, 'case_short'),
detail_confirm=details_helper.get_detail_id_safe(module, 'case_long'),
)],
),
stack=Stack(),
)
frame = PushFrame()
# Open first form in module
frame.add_command(XPath.string(id_strings.menu_id(module)))
frame.add_datum(StackDatum(id=CALCULATED_DATA, value=XPath.string(MARK_AS_CLAIMED)))
sync_request.stack.add_frame(frame)
return [sync_request]
return []