(user, domain)
Each time a CommCareUser is saved this method gets called and creates or updates
    a case associated with the user with the user's details.

    This is also called to create usercases when the usercase is used for the
    first time.
Each time a CommCareUser is saved this method gets called and creates or updates
    a case associated with the user with the user's details.
Each time a CommCareUser is saved this method gets called and creates or updates a case associated with the user with the user s details .
def sync_usercases(user, domain):
    """
    Each time a CommCareUser is saved this method gets called and creates or updates
    a case associated with the user with the user's details.

    This is also called to create usercases when the usercase is used for the
    first time.
    """
    domain_obj = Domain.get_by_name(domain)
    with CriticalSection(get_sync_lock_key(user._id, domain)):
        helpers = list(chain(
            _iter_sync_usercase_helpers(user, domain_obj),
            _iter_call_center_case_helpers(user),
        ))
        if helpers:
            _UserCaseHelper.commit(helpers)
def sync_usercases ( user , domain ) : domain_obj = Domain . get_by_name ( domain ) with CriticalSection ( get_sync_lock_key ( user . _id , domain ) ) : helpers = list ( chain ( _iter_sync_usercase_helpers ( user , domain_obj ) , _iter_call_center_case_helpers ( user ) , ) ) if helpers : _UserCaseHelper . commit ( helpers )