本文整理匯總了Python中corehq.apps.receiverwrapper.models.Repeater.get_db方法的典型用法代碼示例。如果您正苦於以下問題:Python Repeater.get_db方法的具體用法?Python Repeater.get_db怎麽用?Python Repeater.get_db使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類corehq.apps.receiverwrapper.models.Repeater
的用法示例。
在下文中一共展示了Repeater.get_db方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: quick_find
# 需要導入模塊: from corehq.apps.receiverwrapper.models import Repeater [as 別名]
# 或者: from corehq.apps.receiverwrapper.models.Repeater import get_db [as 別名]
def quick_find(request):
query = request.GET.get('q')
redirect = request.GET.get('redirect') != 'false'
if not query:
return HttpResponseBadRequest('GET param "q" must be provided')
def deal_with_couch_doc(doc):
domain = doc.get('domain') or doc.get('domains', [None])[0]
if request.couch_user.is_superuser or (domain and request.couch_user.is_domain_admin(domain)):
doc_info = get_doc_info(doc, domain_hint=domain)
else:
raise Http404()
if redirect and doc_info.link:
messages.info(request, _("We've redirected you to the %s matching your query") % doc_info.type_display)
return HttpResponseRedirect(doc_info.link)
else:
return json_response(doc_info)
try:
doc = get_db().get(query)
except ResourceNotFound:
pass
else:
return deal_with_couch_doc(doc)
try:
doc = Repeater.get_db().get(query)
except ResourceNotFound:
pass
else:
return deal_with_couch_doc(doc)
raise Http404()