diff foodtruck/views/edit.py @ 658:a920b2ab1f31

admin: Fix OS-specific new line problems when editing pages.
author Ludovic Chabant <ludovic@chabant.com>
date Thu, 25 Feb 2016 23:26:36 -0800
parents efc1dc916e7c
children 4d8e82641597
line wrap: on
line diff
--- a/foodtruck/views/edit.py	Thu Feb 25 22:30:16 2016 -0800
+++ b/foodtruck/views/edit.py	Thu Feb 25 23:26:36 2016 -0800
@@ -33,7 +33,7 @@
         if 'do_preview' in request.form or 'do_save' in request.form or \
                 'do_save_and_commit' in request.form:
             logger.debug("Writing page: %s" % page.path)
-            with open(page.path, 'w', encoding='utf8') as fp:
+            with open(page.path, 'w', encoding='utf8', newline='') as fp:
                 fp.write(page_text)
             flash("%s was saved." % os.path.relpath(
                     page.path, site_app.root_dir))
@@ -66,7 +66,7 @@
     data = {}
     data['is_new_page'] = False
     data['url_cancel'] = url_for('list_source', source_name=page.source.name)
-    with open(page.path, 'r', encoding='utf8') as fp:
+    with open(page.path, 'r', encoding='utf8', newline='') as fp:
         data['page_text'] = fp.read()
     data['is_dos_nl'] = "1" if '\r\n' in data['page_text'] else "0"