]> git.llucax.com Git - software/pymin.git/blobdiff - pymin/validatedclass.py
Use ip command to configure VPN networks in vpn service (closes #34)
[software/pymin.git] / pymin / validatedclass.py
index 1e13fe7c9d867e8c3c3e2ce4521e2dd84a5f7945..b94f2b29ca8aa04c4c8a43893aee5dbd96312a63 100644 (file)
@@ -232,6 +232,9 @@ if __name__ == '__main__':
         name = Field(formencode.validators.String(not_empty=True))
         age = Field(formencode.validators.Int(max=110, if_empty=None,
                                                        if_missing=None))
         name = Field(formencode.validators.String(not_empty=True))
         age = Field(formencode.validators.Int(max=110, if_empty=None,
                                                        if_missing=None))
+        def __init__(self, *args, **kwargs):
+            ValidatedClass.__init__(self, *args, **kwargs)
+            self.a_dict = dict()
         # Some global validation after individual fields validation
         def chained_validator(self, fields, state):
             if 'Jr' in fields['name'] and fields['age'] > 25:
         # Some global validation after individual fields validation
         def chained_validator(self, fields, state):
             if 'Jr' in fields['name'] and fields['age'] > 25:
@@ -253,6 +256,11 @@ if __name__ == '__main__':
                        # Use the order of fields declaration
     assert t.name == 'Graham'
 
                        # Use the order of fields declaration
     assert t.name == 'Graham'
 
+    # we can use regular fields too
+    t.a_dict.update(dict(python=True))
+    assert 'python' in t.a_dict
+    assert t.a_dict['python'] is True
+
     t = Test('Graham', 20)
     assert t.name == 'Graham' and t.age == 20
 
     t = Test('Graham', 20)
     assert t.name == 'Graham' and t.age == 20