diff options
Diffstat (limited to 'flatpages/views.py')
-rw-r--r-- | flatpages/views.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/flatpages/views.py b/flatpages/views.py index 3a1bc40..cc1feef 100644 --- a/flatpages/views.py +++ b/flatpages/views.py @@ -128,7 +128,6 @@ def editflatpage(request, path): if request.method == 'POST': # If the form has been submitted... flatpageForm = FlatPageForm(request.POST) # A form bound to the POST data if flatpageForm.is_valid():# Form valid therefore write file - f = open(filepath, "w") if filefound: headmatch = re.match(r"(.*)<title>.*</title>(.*)", head, re.DOTALL + re.IGNORECASE) if headmatch: @@ -144,7 +143,9 @@ def editflatpage(request, path): postbody = "</html>" body = flatpageForm.cleaned_data["html"] body = body.replace("\r", "") - f.write("%s<head%s>%s</head>%s<body%s>\n%s</body>%s" % (preheader, headerargs, head, postheader, bodyargs, body, postbody)) + result = u"%s<head%s>%s</head>%s<body%s>\n%s</body>%s" % (preheader, headerargs, head, postheader, bodyargs, body, postbody) + f = open(filepath, "w") + f.write(result) f.close() return HttpResponseRedirect(reverse('flatpage', args=[path])) # Redirect after POST else: |