def __init__(self, contain_type, register=True): BaseType.__init__(self, pkey=False, default=[]) self.register = register self.contain_type = None if register and not contain_type: raise ValueError("a registered list MUST have a contain_type " \ "specified") if contain_type: # We try to find the type in types types = importlib.import_module("model.types") try: field_type = getattr(types, contain_type) except AttributeError: raise ValueError("the {} field type cannot be " \ "found".format(repr(contain_type))) from None if field_type not in [types.Integer, types.String]: raise ValueError("the {} field type can't be stored " \ "in a list".format(repr(contain_type))) self.contain_type = field_type
def __init__(self, default=None, **kwargs): BaseType.__init__(self, default, **kwargs)
def __init__(self): BaseType.__init__(self, pkey=False, default=None) self.register = False self.foreign_model = None