We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 603da4b commit ad60f39Copy full SHA for ad60f39
flask_mongoengine/db_fields.py
@@ -41,6 +41,8 @@
41
"URLField",
42
"UUIDField",
43
]
44
+import functools
45
+import logging
46
from typing import Callable, List, Optional, Union
47
48
from mongoengine import fields
@@ -52,6 +54,22 @@
52
54
wtf_fields = None
53
55
wtf_validators = None
56
57
+logger = logging.getLogger("flask_mongoengine")
58
+
59
60
+def wtf_required(func):
61
+ """Special decorator to warn user on incorrect installation."""
62
63
+ @functools.wraps(func)
64
+ def wrapped(*args, **kwargs):
65
+ if wtf_validators is None or wtf_fields is None:
66
+ logger.error(f"WTForms not installed. Function '{func.__name__}' aborted.")
67
+ return None
68
69
+ return func(*args, **kwargs)
70
71
+ return wrapped
72
73
74
class WtfFieldMixin:
75
"""
0 commit comments