Changed a few fields to be optional.

Found a fairly difficult bug involved with Field instances
being shared across Records. The issue is that Field instances
are static. I either need to implement a way to instantiate
copies of all the Fields per-record, or write a wrapping
interface which provides a unique value store on a per-Record
basis.
This commit is contained in:
Binh 2011-10-25 14:54:22 -05:00
parent 775d3d3700
commit 4023d46b4a
4 changed files with 35 additions and 18 deletions

View file

@ -12,6 +12,7 @@ class ValidationError(Exception):
return "(%s.%s) %s" % (self.field.parent_name, self.field.name, self.msg)
else:
return repr(self.msg)
class Field(object):
creation_counter = 0
@ -49,6 +50,12 @@ class Field(object):
self.value = s.strip()
class FieldInterface(object):
def __init__(self, value_dict, field):
self.value_dict = value_dict
self.field = field
class TextField(Field):
def validate(self):
if self.value == None and self.required: