# Path: webtools/formdata/exceptions.py
# class ValidateError(Exception):
#     pass
# 
# Path: webtools/formdata/field.py
# class Field(object):
#     def __init__(self, datatype, widget=None, required=True, default=None):
#         assert isinstance(datatype, data_types.Type), "datatype must be a instance of Type"
#         self.datatype = datatype
#         self.default = default
#         self.required = required
#         self.widget = widget
# 
#         if self.widget:
#             if isinstance(self.widget, type):
#                 self.widget = self.widget()
#             assert isinstance(self.widget, Widget), "widget must be a instance of Widget"
# 
#     def clean(self, name, formdata):
#         raw_value = formdata.get_argument(name)
#         if raw_value:
#             return self.datatype.to_python(raw_value, self)
#         else:
#             if not self.required:
#                 return self.default
#             raise ValidateError("this field is required")
# 
# class BoundField(object):
#     def __init__(self, name, prefixed_name, field, form):
#         self.name = name
#         self.prefixed_name = prefixed_name
#         self.field = field
#         self.form = form
# 
#     def __str__(self):
#         if not self.field.widget:
#             return ""
# 
#         value = self.form._initial.get(self.name, None)
#         value = self.field.datatype.from_python(value)
# 
#         return self.field.widget(self.name, self.prefixed_name, value)


from .exceptions import ValidateError
from .field import Field, BoundField
import copy
        self.handler = handler
        self.initial = initial

        self.prefix = None
        self.errors = {}

        self._validated = False
        self._initial = copy.deepcopy(self.initial)

    def with_prefix(self, name):
        if self.prefix is None:
            return name
        return "{0}-{1}".format(self.prefix, name)

    def _field_validate(self):
        for field_name, field in self.base_fields.items():
            field_name_with_prefix = self.with_prefix(field_name)
            try:
                value = field.clean(field_name_with_prefix, self)
                if not field.required and value is None:
                    continue

                self.cleaned_data[field_name] = value

            except ValidateError as e:
                self.errors[field_name] = list(e.args)

    def _form_validate(self):
        try:
            self.cleaned_data = self.clean()

# Path: webtools/formdata/exceptions.py
# class ValidateError(Exception):
#     pass
# 
# Path: webtools/formdata/field.py
# class Field(object):
#     def __init__(self, datatype, widget=None, required=True, default=None):
#         assert isinstance(datatype, data_types.Type), "datatype must be a instance of Type"
#         self.datatype = datatype
#         self.default = default
#         self.required = required
#         self.widget = widget
# 
#         if self.widget:
#             if isinstance(self.widget, type):
#                 self.widget = self.widget()
#             assert isinstance(self.widget, Widget), "widget must be a instance of Widget"
# 
#     def clean(self, name, formdata):
#         raw_value = formdata.get_argument(name)
#         if raw_value:
#             return self.datatype.to_python(raw_value, self)
#         else:
#             if not self.required:
#                 return self.default
#             raise ValidateError("this field is required")
# 
# class BoundField(object):
#     def __init__(self, name, prefixed_name, field, form):
#         self.name = name
#         self.prefixed_name = prefixed_name
#         self.field = field
#         self.form = form
# 
#     def __str__(self):
#         if not self.field.widget:
#             return ""
# 
#         value = self.form._initial.get(self.name, None)
#         value = self.field.datatype.from_python(value)
# 
#         return self.field.widget(self.name, self.prefixed_name, value)


# Path: webtools/formdata/base.py
from .exceptions import ValidateError
from .field import Field, BoundField
import copy

        self.handler = handler
        self.initial = initial

        self.prefix = None
        self.errors = {}

        self._validated = False
        self._initial = copy.deepcopy(self.initial)

    def with_prefix(self, name):
        if self.prefix is None:
            return name
        return "{0}-{1}".format(self.prefix, name)

    def _field_validate(self):
        for field_name, field in self.base_fields.items():
            field_name_with_prefix = self.with_prefix(field_name)
            try:
                value = field.clean(field_name_with_prefix, self)
                if not field.required and value is None:
                    continue

                self.cleaned_data[field_name] = value

            except ValidateError as e:
                self.errors[field_name] = list(e.args)

    def _form_validate(self):
        try:
            self.cleaned_data = self.clean()

        except ValidateError as e: