Commits

Andriy Kornatskyy committed 34e83e6

Fixed #1: try_update_model implicitly adds defaults if values is defaultdict

  • Participants
  • Parent commits ecf3f96

Comments (0)

Files changed (4)

File doc/userguide.rst

 List of supported ``value_providers``:
 
 .. literalinclude:: ../src/wheezy/validation/model.py
-   :lines: 328-
+   :lines: 329-
 
 Example of domain model initialized with defaults::
 

File i18n/en/LC_MESSAGES/validation.po

 "%Y/%m/%d %H:%M:%S|%m/%d/%Y %H:%M|%m/%d/%Y %H:%M:%S|%Y-%m-%d %H:%M|%Y-%m-%d "
 "%H:%M:%S|%m/%d/%y %H:%M|%m/%d/%y %H:%M:%S"
 
-#: src/wheezy/validation/model.py:130 src/wheezy/validation/model.py:132
+#: src/wheezy/validation/model.py:131 src/wheezy/validation/model.py:132
 #: src/wheezy/validation/model.py:135
 msgid "Multiple input was not in a correct format."
 msgstr "Multiple input was not in a correct format."
 
-#: src/wheezy/validation/model.py:145 src/wheezy/validation/model.py:147
+#: src/wheezy/validation/model.py:146 src/wheezy/validation/model.py:147
 #: src/wheezy/validation/model.py:150
 #, python-format
 msgid "The value '%s' is not in one of supported formats."
 msgstr "The value '%s' is not in one of supported formats."
 
-#: src/wheezy/validation/model.py:155 src/wheezy/validation/model.py:158
+#: src/wheezy/validation/model.py:154 src/wheezy/validation/model.py:158
 #, python-format
 msgid "The value '%s' is invalid."
 msgstr "The value '%s' is invalid."
 
-#: src/wheezy/validation/model.py:158 src/wheezy/validation/model.py:161
+#: src/wheezy/validation/model.py:157 src/wheezy/validation/model.py:161
 msgid "Input was not in a correct format."
 msgstr "Input was not in a correct format."
 

File i18n/validation.po

 "%Y/%m/%d %H:%M:%S|%m/%d/%Y %H:%M|%m/%d/%Y %H:%M:%S|%Y-%m-%d %H:%M|%Y-%m-%d "
 "%H:%M:%S|%m/%d/%y %H:%M|%m/%d/%y %H:%M:%S"
 
-#: src/wheezy/validation/model.py:130 src/wheezy/validation/model.py:132
+#: src/wheezy/validation/model.py:131 src/wheezy/validation/model.py:132
 #: src/wheezy/validation/model.py:135
 msgid "Multiple input was not in a correct format."
 msgstr "Multiple input was not in a correct format."
 
-#: src/wheezy/validation/model.py:145 src/wheezy/validation/model.py:147
+#: src/wheezy/validation/model.py:146 src/wheezy/validation/model.py:147
 #: src/wheezy/validation/model.py:150
 #, python-format
 msgid "The value '%s' is not in one of supported formats."
 msgstr "The value '%s' is not in one of supported formats."
 
-#: src/wheezy/validation/model.py:155 src/wheezy/validation/model.py:158
+#: src/wheezy/validation/model.py:154 src/wheezy/validation/model.py:158
 #, python-format
 msgid "The value '%s' is invalid."
 msgstr "The value '%s' is invalid."
 
-#: src/wheezy/validation/model.py:158 src/wheezy/validation/model.py:161
+#: src/wheezy/validation/model.py:157 src/wheezy/validation/model.py:161
 msgid "Input was not in a correct format."
 msgstr "Input was not in a correct format."
 

File src/wheezy/validation/model.py

         setter = setattr
     succeed = True
     for name in attribute_names:
-        try:
-            value = values[name]
-        except KeyError:
+        if name not in values:
             continue
+        value = values[name]
         attr = getter(model, name)
         # Check if we have a deal with list like attribute
         if hasattr(attr, '__setitem__'):