Permalink
Browse files

fixing flags for required fields

  • Loading branch information...
1 parent d5a652c commit 9254b857bacb27f83b94a0e899597a9a71228f42 @alvesjnr alvesjnr committed with gustavofonseca May 30, 2011
Showing with 14 additions and 4 deletions.
  1. +14 −4 isis/model/mapper.py
View
@@ -283,10 +283,14 @@ def _pystruct(self, instance, value):
return value.items()
def _colander_schema(self, instance, value):
- subfield = colander.SchemaNode(colander.Mapping(), name=self.name)
+ subfield = colander.SchemaNode(colander.Mapping(), name=self.name,)
+
+ kwargs = {}
+ if not self.required:
+ kwargs.update({'missing':None})
for subkey in self.subkeys:
- subfield.add(colander.SchemaNode(colander.String(), name=subkey))
+ subfield.add(colander.SchemaNode(colander.String(), name=subkey, **kwargs))
return subfield
@@ -345,12 +349,18 @@ def _pystruct(self, instance, value):
def _colander_schema(self, instance, value):
schema = colander.SchemaNode(colander.Mapping(), name=self.name)
+
+ kwargs = {}
+ if not self.required:
+ kwargs.update({'missing':None})
+
for subkey in self.subkeys:
- schema.add(colander.SchemaNode(colander.String(), name=subkey))
+ schema.add(colander.SchemaNode(colander.String(), name=subkey, **kwargs))
return colander.SchemaNode(colander.Sequence(),
schema,
- name=self.name)
+ name=self.name,
+ **kwargs)
class ReferenceProperty(CheckedProperty):

0 comments on commit 9254b85

Please sign in to comment.