Hi All,
This is a bit of a tricky one to explain. Essentially I have a custom validation module which allows one to check whether their csv for upload is in the expected format.
The validation module generates and returns a text-based report as a single string e.g. "Line1\nLine2\nLine3"
The csv is uploaded via a view & controller as below.
Controller:
def validate_test():
report = ""
form = SQLFORM.factory(
Field('csvfile', 'upload'), table_name="dataset_upload")
if form.validate():
origin_filename = request.vars.csvfile.filename
temp_filename = form.vars.csvfile
with open(request.folder + "uploads/" + form.vars.csvfile) as candidate_src:
candidate_reader = csv.reader(candidate_src, quotechar='"')
candidate = [x for x in candidate_reader]
# Process
logger.setLevel(logging.INFO)
report = validatemodule.validate(candidate, origin_filename)
if form.process().accepted:
response.flash = 'form accepted'
elif form.errors:
response.flash = 'form has errors'
return dict(form=form, report=report)
View:
{{extend 'layout.html'}}
<div style="background: linear-gradient(240deg, lightgrey, whitesmoke)" class="jumbotron">
{{=form}}
{{=report}}
</div>
Now for some reason whilst the report does get returned to the view, all line breaks in the report string seem to be ignored:

I'm sure there's just something that I'm missing here, but even when digging through the HTML helper functions I'm just not finding what I need.
Anyone got an idea on what's going on?
Thanks!