Repository: flask-admin/flask-admin

Issue:
Incompatibility problem with wtforms 3.0.0a1
FileUploadField seems to be incompatible with wtforms >= 3.0.0a1
The problem is:
`TypeError: process() got an unexpected keyword argument 'extra_filters'`
The process function overridden in the FileUploadFile class does not specify 'extra_filters' as a keyword argument.

wtforms==2.3.3 works, at least for this issue.



Discussion:
I can take a look at this issue this week. Thanks for the report!
@zapfdk can you please provide a minimal working example that demonstrates the issue, so I can jump right into the issue once I get to it this week?
```
from flask import Flask
from flask_admin import Admin, form
from flask_admin.contrib.sqla import ModelView

from sqlalchemy import create_engine, Integer, Column
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker

app = Flask(__name__)

engine = create_engine("sqlite:///./test.db")
Session = sessionmaker(autocommit=False, autoflush=False, bind=engine)
session = Session()

Base = declarative_base()


class TestModel(Base):
    __tablename__ = "test_model"
    id = Column(Integer, primary_key=True)


class TestModelView(ModelView):
    form_extra_fields = {
        "file_upload": form.FileUploadField()
    }


Base.metadata.drop_all(bind=engine)
Base.metadata.create_all(bind=engine)

admin = Admin(app)
admin.add_view(TestModelView(TestModel, session))


if __name__ == "__main__":
    app.run()
```

with:
```
flask-admin = "*"
wtforms = "==3.0.0a1"
sqlalchemy = "*"
```
Should be enough to reproduce the error.
I think it should be enough to add and pass on the new `extra_filters` parameter to the inherited `process` function?
https://wtforms.readthedocs.io/en/3.0.x/forms/#wtforms.form.BaseForm.process

Thanks for the example, I'll have a look at this later today.


Resolving patch:
diff --git a/flask_admin/form/upload.py b/flask_admin/form/upload.py
--- a/flask_admin/form/upload.py
+++ b/flask_admin/form/upload.py
@@ -4,7 +4,7 @@
 from werkzeug.utils import secure_filename
 from werkzeug.datastructures import FileStorage
 
-from wtforms import ValidationError, fields
+from wtforms import ValidationError, fields, __version__ as wtforms_version
 from wtforms.widgets import html_params
 
 try:
@@ -186,6 +186,9 @@ class MyForm(BaseForm):
 
         self._should_delete = False
 
+        if int(wtforms_version[0]) < 3:
+            kwargs.pop('extra_filters', None)
+
         super(FileUploadField, self).__init__(label, validators, **kwargs)
 
     def is_file_allowed(self, filename):
@@ -216,13 +219,16 @@ def pre_validate(self, form):
         if not self._allow_overwrite and os.path.exists(self._get_path(self.data.filename)):
             raise ValidationError(gettext('File "%s" already exists.' % self.data.filename))
 
-    def process(self, formdata, data=unset_value):
+    def process(self, formdata, data=unset_value, extra_filters=None):
         if formdata:
             marker = '_%s-delete' % self.name
             if marker in formdata:
                 self._should_delete = True
 
-        return super(FileUploadField, self).process(formdata, data)
+        if int(wtforms_version[0]) < 3:
+            return super(FileUploadField, self).process(formdata, data)
+        else:
+            return super(FileUploadField, self).process(formdata, data, extra_filters)  # noqa
 
     def process_formdata(self, valuelist):
         if self._should_delete:


Test patch: