예제 #1
0
파일: list_pa.py 프로젝트: v-legoff/pa-poc3
    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
예제 #2
0
 def __init__(self, default=None, **kwargs):
     BaseType.__init__(self, default, **kwargs)
예제 #3
0
파일: related.py 프로젝트: v-legoff/pa-poc3
 def __init__(self):
     BaseType.__init__(self, pkey=False, default=None)
     self.register = False
     self.foreign_model = None