コード例 #1
0
ファイル: fields.py プロジェクト: abilian/abilian-core
    def __init__(self, *args, **kwargs):
        try:
            self.multiple = kwargs.pop("multiple")
        except KeyError:
            self.multiple = False

        self.blob_attr = kwargs.pop("blob_attr", self.__class__.blob_attr)
        allow_delete = kwargs.pop("allow_delete", None)
        validators = list(kwargs.get("validators", []))
        self.upload_handles = []
        self.delete_files_index = []
        self._has_uploads = False

        if allow_delete is not None:
            if any(
                isinstance(v, DataRequired if allow_delete else Optional)
                for v in validators
            ):
                raise ValueError(
                    "Field validators are conflicting with `allow_delete`,"
                    "validators={!r}, allow_delete={!r}".format(
                        validators, allow_delete
                    )
                )
            if not allow_delete:
                validators.append(DataRequired())

        kwargs["validators"] = validators
        BaseFileField.__init__(self, *args, **kwargs)
コード例 #2
0
ファイル: fields.py プロジェクト: abilian/abilian-core
 def __call__(self, **kwargs):
     if "multiple" not in kwargs and self.multiple:
         kwargs["multiple"] = "multiple"
     return BaseFileField.__call__(self, **kwargs)
コード例 #3
0
ファイル: fields.py プロジェクト: debon/abilian-core
 def __call__(self, **kwargs):
   if 'multiple' not in kwargs and self.multiple:
     kwargs['multiple'] = 'multiple'
   return BaseFileField.__call__(self, **kwargs)