(self, name, fieldtype, glob=False)
Adds a field to this schema.

        :param name: The name of the field.
        :param fieldtype: An instantiated fields.FieldType object, or a
            FieldType subclass. If you pass an instantiated object, the schema
            will use that as the field configuration for this field. If you
            pass a FieldType subclass, the schema will automatically
            instantiate it with the default constructor.
Adds a field to this schema.
Adds a field to this schema .
def add(self, name, fieldtype, glob=False):
        """Adds a field to this schema.

        :param name: The name of the field.
        :param fieldtype: An instantiated fields.FieldType object, or a
            FieldType subclass. If you pass an instantiated object, the schema
            will use that as the field configuration for this field. If you
            pass a FieldType subclass, the schema will automatically
            instantiate it with the default constructor.
        """

        # Check field name
        if name.startswith("_"):
            raise FieldConfigurationError("Field names cannot start with an "
                                          "underscore")
        if " " in name:
            raise FieldConfigurationError("Field names cannot contain spaces")
        if name in self._fields or (glob and name in self._dyn_fields):
            raise FieldConfigurationError("Schema already has a field %r"
                                          % name)

        # If the user passed a type rather than an instantiated field object,
        # instantiate it automatically
        if type(fieldtype) is type:
            try:
                fieldtype = fieldtype()
            except:
                e = sys.exc_info()[1]
                raise FieldConfigurationError("Error: %s instantiating field "
                                              "%r: %r" % (e, name, fieldtype))

        if not isinstance(fieldtype, FieldType):
                raise FieldConfigurationError("%r is not a FieldType object"
                                              % fieldtype)

        if glob:
            expr = re.compile(fnmatch.translate(name))
            self._dyn_fields[name] = (expr, fieldtype)
        else:
            fieldtype.on_add(self, name)
            self._fields[name] = fieldtype
def add ( self , name , fieldtype , glob = False ) : # Check field name if name . startswith ( "_" ) : raise FieldConfigurationError ( "Field names cannot start with an " "underscore" ) if " " in name : raise FieldConfigurationError ( "Field names cannot contain spaces" ) if name in self . _fields or ( glob and name in self . _dyn_fields ) : raise FieldConfigurationError ( "Schema already has a field %r" % name ) # If the user passed a type rather than an instantiated field object, # instantiate it automatically if type ( fieldtype ) is type : try : fieldtype = fieldtype ( ) except : e = sys . exc_info ( ) [ 1 ] raise FieldConfigurationError ( "Error: %s instantiating field " "%r: %r" % ( e , name , fieldtype ) ) if not isinstance ( fieldtype , FieldType ) : raise FieldConfigurationError ( "%r is not a FieldType object" % fieldtype ) if glob : expr = re . compile ( fnmatch . translate ( name ) ) self . _dyn_fields [ name ] = ( expr , fieldtype ) else : fieldtype . on_add ( self , name ) self . _fields [ name ] = fieldtype