本文整理汇总了Python中casexml.apps.case.models.CommCareCase.get_lite方法的典型用法代码示例。如果您正苦于以下问题:Python CommCareCase.get_lite方法的具体用法?Python CommCareCase.get_lite怎么用?Python CommCareCase.get_lite使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类casexml.apps.case.models.CommCareCase
的用法示例。
在下文中一共展示了CommCareCase.get_lite方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from casexml.apps.case.models import CommCareCase [as 别名]
# 或者: from casexml.apps.case.models.CommCareCase import get_lite [as 别名]
def get(self, case_id):
if not case_id:
raise IllegalCaseId('case_id must not be empty')
if case_id in self.cache:
return self.cache[case_id]
try:
if self.strip_history:
case_doc = CommCareCase.get_lite(case_id, wrap=self.wrap)
elif self.lock:
try:
case_doc, lock = CommCareCase.get_locked_obj(_id=case_id)
except redis.RedisError:
case_doc = CommCareCase.get(case_id)
else:
self.locks.append(lock)
else:
if self.wrap:
case_doc = CommCareCase.get(case_id)
else:
case_doc = CommCareCase.get_db().get(case_id)
except ResourceNotFound:
return None
self.validate_doc(case_doc)
self.cache[case_id] = case_doc
return case_doc
示例2: get_case_with_lock
# 需要导入模块: from casexml.apps.case.models import CommCareCase [as 别名]
# 或者: from casexml.apps.case.models.CommCareCase import get_lite [as 别名]
def get_case_with_lock(case_id, lock=False, strip_history=False, wrap=False):
def _get_case():
if wrap:
return CommCareCase.get(case_id)
else:
return CommCareCase.get_db().get(case_id)
try:
if strip_history:
case_doc = CommCareCase.get_lite(case_id, wrap=wrap)
elif lock:
try:
case, lock = CommCareCase.get_locked_obj(_id=case_id)
if case and not wrap:
case = case.to_json()
return case, lock
except redis.RedisError:
case_doc = _get_case()
else:
case_doc = _get_case()
except ResourceNotFound:
return None, None
return case_doc, None
示例3: _cached_case_id_to_case_name
# 需要导入模块: from casexml.apps.case.models import CommCareCase [as 别名]
# 或者: from casexml.apps.case.models.CommCareCase import get_lite [as 别名]
def _cached_case_id_to_case_name(case_id):
key = 'case_id_to_case_name_cache_{id}'.format(id=case_id)
ret = cache.get(key, NULL_CACHE_VALUE)
if ret != NULL_CACHE_VALUE:
return ret
try:
case = CommCareCase.get_lite(case_id)
ret = case['name'] if "name" in case else None
except ResourceNotFound:
ret = None
cache.set(key, ret)
return ret
示例4: _get_case
# 需要导入模块: from casexml.apps.case.models import CommCareCase [as 别名]
# 或者: from casexml.apps.case.models.CommCareCase import get_lite [as 别名]
def _get_case(self, case_id):
try:
if self.strip_history:
case_doc = CommCareCase.get_lite(case_id, wrap=self.wrap)
elif self.lock:
try:
case_doc, lock = CommCareCase.get_locked_obj(_id=case_id)
except redis.RedisError:
case_doc = CommCareCase.get(case_id)
else:
self.locks.append(lock)
else:
if self.wrap:
case_doc = CommCareCase.get(case_id)
else:
case_doc = CommCareCase.get_db().get(case_id)
except ResourceNotFound:
return None
return case_doc