changeset 1626:346c52c9c1e5

Fixes to forms.py and items/__init__.py forms.py: Add a missing `import json`; add spy's comment on the `except:` in ValidJSON.validate; items/__init__.py: Add a missing empty line.
author Cheer Xiao <xiaqqaix@gmail.com>
date Sun, 05 Aug 2012 21:55:45 +0800
parents 6748d609a242
children b0b73fe90f3d
files MoinMoin/forms.py MoinMoin/items/__init__.py
diffstat 2 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/forms.py	Wed Aug 01 23:32:42 2012 +0800
+++ b/MoinMoin/forms.py	Sun Aug 05 21:55:45 2012 +0800
@@ -10,6 +10,7 @@
 
 
 import re
+import json
 
 from flatland import Element, Form, String, Integer, Boolean, Enum, Dict, DateTime as _DateTime, JoinedString
 from flatland.validation import Validator, Present, IsEmail, ValueBetween, URLValidator, Converted, ValueAtLeast
@@ -41,7 +42,7 @@
     def validate(self, element, state):
         try:
             json.loads(element.value)
-        except:
+        except: # catch ANY exception that happens due to unserializing
             return self.note_error(element, state, 'invalid_json_msg')
         return True
 
--- a/MoinMoin/items/__init__.py	Wed Aug 01 23:32:42 2012 +0800
+++ b/MoinMoin/items/__init__.py	Sun Aug 05 21:55:45 2012 +0800
@@ -127,6 +127,7 @@
     summary = OptionalText.using(label=L_("Summary")).with_properties(placeholder=L_("One-line summary of the item"))
     tags = Tags
 
+
 class Item(object):
     """ Highlevel (not storage) Item, wraps around a storage Revision"""
     @classmethod