[Checkins] SVN: z3c.form/trunk/ Fix DictionaryField to conform to the IDataManager spec: get() should raise an exception if no value can be found.
Wichert Akkerman
wichert at wiggy.net
Mon May 10 11:03:42 EDT 2010
Log message for revision 112225:
Fix DictionaryField to conform to the IDataManager spec: get() should raise an exception if no value can be found.
Changed:
U z3c.form/trunk/CHANGES.txt
U z3c.form/trunk/src/z3c/form/datamanager.py
U z3c.form/trunk/src/z3c/form/datamanager.txt
-=-
Modified: z3c.form/trunk/CHANGES.txt
===================================================================
--- z3c.form/trunk/CHANGES.txt 2010-05-10 14:59:34 UTC (rev 112224)
+++ z3c.form/trunk/CHANGES.txt 2010-05-10 15:03:42 UTC (rev 112225)
@@ -8,6 +8,10 @@
- Bugfix: applyChanges should not try to compare old and new values of the old
value can not be accessed.
+- Fix DictionaryField to conform to the IDataManager spec: get() should raise
+ an exception if no value can be found.
+
+
2.3.3 (2010-04-20)
------------------
Modified: z3c.form/trunk/src/z3c/form/datamanager.py
===================================================================
--- z3c.form/trunk/src/z3c/form/datamanager.py 2010-05-10 14:59:34 UTC (rev 112224)
+++ z3c.form/trunk/src/z3c/form/datamanager.py 2010-05-10 15:03:42 UTC (rev 112225)
@@ -28,6 +28,7 @@
from z3c.form import interfaces
+_marker = []
class DataManager(object):
"""Data manager base class."""
@@ -117,7 +118,10 @@
def get(self):
"""See z3c.form.interfaces.IDataManager"""
- return self.data.get(self.field.__name__, self.field.missing_value)
+ value = self.data.get(self.field.__name__, _marker)
+ if value is _marker:
+ raise AttributeError
+ return value
def query(self, default=interfaces.NO_VALUE):
"""See z3c.form.interfaces.IDataManager"""
Modified: z3c.form/trunk/src/z3c/form/datamanager.txt
===================================================================
--- z3c.form/trunk/src/z3c/form/datamanager.txt 2010-05-10 14:59:34 UTC (rev 112224)
+++ z3c.form/trunk/src/z3c/form/datamanager.txt 2010-05-10 15:03:42 UTC (rev 112225)
@@ -283,6 +283,9 @@
Let's now access the name:
>>> nameDm.get()
+ Traceback (most recent call last):
+ ...
+ AttributeError
>>> nameDm.query()
<NO_VALUE>
More information about the checkins
mailing list