1. psviderski
  2. moin-2.0


psviderski  committed 100ab72

Add some explicit checks for the optional fields of ModifyForm

  • Participants
  • Parent commits 78ed0ce
  • Branches default

Comments (0)

Files changed (2)

File MoinMoin/items/__init__.py

View file
  • Ignore whitespace
+# Copyright: 2012-2013 MoinMoin:PavelSviderski
 # Copyright: 2012 MoinMoin:CheerXiao
 # Copyright: 2009 MoinMoin:ThomasWaldmann
 # Copyright: 2009-2011 MoinMoin:ReimarBauer
 from flask import g as flaskg
 from flask import request, Response, redirect, abort, escape
-from flatland import Form
+from flatland import Form, Unset
 from jinja2 import Markup
             meta = self['meta_form'].value.copy()
-            meta.update(item.meta_text_to_dict(self['extra_meta_text'].value))
+            if self['extra_meta_text'].raw is not Unset:  # it's an optional field
+                meta.update(item.meta_text_to_dict(self['extra_meta_text'].value))
             data, contenttype_guessed = self['content_form']._dump(item.content)
             comment = self['comment'].value
             return meta, data, contenttype_guessed, comment

File MoinMoin/items/content.py

View file
  • Ignore whitespace
 from flask import g as flaskg
 from flask import request, url_for, Response, abort, escape
-from flatland import Form, String
+from flatland import Form, String, Unset
 from jinja2 import Markup
         def _dump(self, item):
             data, contenttype_guessed = super(Text.ModifyForm, self)._dump(item)
-            if data is None:
+            if data is None and self['data_text'].raw is not Unset:  # data_text is an optional field
                 data = self['data_text'].value
                 data = item.data_form_to_internal(data)
                 data = item.data_internal_to_storage(data)