@login_required
@ensure_csrf_cookie
@require_http_methods(('GET', 'POST', 'PUT'))
@ensure_valid_course_key
def import_handler(request, course_key_string):
 courselike_key = CourseKey.from_string(course_key_string)
 library = isinstance(courselike_key, LibraryLocator)
 if library:
  root_name = LIBRARY_ROOT
  successful_url = reverse_library_url('library_handler', courselike_key)
  context_name = 'context_library'
  courselike_module = modulestore().get_library(courselike_key)
  import_func = import_library_from_xml
 else:
  root_name = COURSE_ROOT
  successful_url = reverse_course_url('course_handler', courselike_key)
  context_name = 'context_course'
  courselike_module = modulestore().get_course(courselike_key)
  import_func = import_course_from_xml
 return _import_handler(request, courselike_key, root_name, successful_url, context_name, courselike_module, import_func)

@ login_required @ ensure_csrf_cookie @ require_http_methods ( ( 'GET' , 'POST' , 'PUT' ) ) @ ensure_valid_course_key def import_handler ( request , course_key_string ) : courselike_key = CourseKey . from_string ( course_key_string ) library = isinstance ( courselike_key , LibraryLocator ) if library : root_name = LIBRARY_ROOT successful_url = reverse_library_url ( 'library_handler' , courselike_key ) context_name = 'context_library' courselike_module = modulestore ( ) . get_library ( courselike_key ) import_func = import_library_from_xml else : root_name = COURSE_ROOT successful_url = reverse_course_url ( 'course_handler' , courselike_key ) context_name = 'context_course' courselike_module = modulestore ( ) . get_course ( courselike_key ) import_func = import_course_from_xml return _import_handler ( request , courselike_key , root_name , successful_url , context_name , courselike_module , import_func )
the restful handler for importing a course .