def _get_xblock(usage_key, user):
 store = modulestore()
 with store.bulk_operations(usage_key.course_key):
  try:
   return store.get_item(usage_key, depth=None)
  except ItemNotFoundError:
   if (usage_key.category in CREATE_IF_NOT_FOUND):
    return store.create_item(user.id, usage_key.course_key, usage_key.block_type, block_id=usage_key.block_id)
   else:
    raise
  except InvalidLocationError:
   log.error("Can't find item by location.")
   return JsonResponse({'error': ("Can't find item by location: " + unicode(usage_key))}, 404)

def _get_xblock ( usage_key , user ) : store = modulestore ( ) with store . bulk_operations ( usage_key . course_key ) : try : return store . get_item ( usage_key , depth = None ) except ItemNotFoundError : if ( usage_key . category in CREATE_IF_NOT_FOUND ) : return store . create_item ( user . id , usage_key . course_key , usage_key . block_type , block_id = usage_key . block_id ) else : raise except InvalidLocationError : log . error ( "Can't find item by location." ) return JsonResponse ( { 'error' : ( "Can't find item by location: " + unicode ( usage_key ) ) } , 404 )
returns the xblock for the specified usage key .