def mobile_course_access(depth=0):
 def _decorator(func):
  'Outer method decorator.'
  @functools.wraps(func)
  def _wrapper(self, request, *args, **kwargs):
   "\n            Expects kwargs to contain 'course_id'.\n            Passes the course descriptor to the given decorated function.\n            Raises 404 if access to course is disallowed.\n            "
   course_id = CourseKey.from_string(kwargs.pop('course_id'))
   with modulestore().bulk_operations(course_id):
    try:
     course = get_course_with_access(request.user, 'load_mobile', course_id, depth=depth, check_if_enrolled=True)
    except CoursewareAccessException as error:
     return Response(data=error.to_json(), status=status.HTTP_404_NOT_FOUND)
    return func(self, request, course=course, *args, **kwargs)
  return _wrapper
 return _decorator

def mobile_course_access ( depth = 0 ) : def _decorator ( func ) : @ functools . wraps ( func ) def _wrapper ( self , request , * args , ** kwargs ) : course_id = CourseKey . from_string ( kwargs . pop ( 'course_id' ) ) with modulestore ( ) . bulk_operations ( course_id ) : try : course = get_course_with_access ( request . user , 'load_mobile' , course_id , depth = depth , check_if_enrolled = True ) except CoursewareAccessException as error : return Response ( data = error . to_json ( ) , status = status . HTTP_404_NOT_FOUND ) return func ( self , request , course = course , * args , ** kwargs ) return _wrapper return _decorator
method decorator for a mobile api endpoint that verifies the user has access to the course in a mobile context .