Permalink
Browse files

CompositeTextProperty mandatory validation

  • Loading branch information...
gustavofonseca committed May 30, 2011
1 parent 23f4a92 commit 75ca06e02816263c92b74da0e3f534ec20d2f333
Showing with 14 additions and 5 deletions.
  1. +14 −5 isis/model/mapper.py
View
@@ -225,7 +225,6 @@ def _colander_schema(self, instance, value):
return schema
-
class IsisCompositeTextProperty(CheckedProperty):
def __init__(self, subkeys=None, **kwargs):
@@ -254,7 +253,6 @@ def _colander_schema(self, instance, value):
subfield,
name=self.name)
-
class CompositeTextProperty(CheckedProperty):
def __init__(self, subkeys, **kwargs):
@@ -280,13 +278,20 @@ def _pystruct(self, instance, value):
'''
python representation for this property
'''
+ #composite_string = tuple((k, v) for k, v in value.items() if v is not None)
+ #return composite_string
+
return value.items()
def _colander_schema(self, instance, value):
- subfield = colander.SchemaNode(colander.Mapping(), name=self.name)
+ #option arg acts in each attribute
+ kwargs = {}
+ if not self.required:
+ kwargs.update({'missing':None})
+ subfield = colander.SchemaNode(colander.Mapping(), name=self.name)
for subkey in self.subkeys:
- subfield.add(colander.SchemaNode(colander.String(), name=subkey))
+ subfield.add(colander.SchemaNode(colander.String(), name=subkey, **kwargs))
return subfield
@@ -344,13 +349,17 @@ def _pystruct(self, instance, value):
return tuple(composite_text.items() for composite_text in value)
def _colander_schema(self, instance, value):
+ kwargs = {'name':self.name}
+ if not self.required:
+ kwargs.update({'missing':None})
+
schema = colander.SchemaNode(colander.Mapping(), name=self.name)
for subkey in self.subkeys:
schema.add(colander.SchemaNode(colander.String(), name=subkey))
return colander.SchemaNode(colander.Sequence(),
schema,
- name=self.name)
+ **kwargs)
class ReferenceProperty(CheckedProperty):

0 comments on commit 75ca06e

Please sign in to comment.