diff MoinMoin/util/forms.py @ 244:a11656ba1eab

modify views: use flatland also for the file upload form field
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 29 May 2011 22:53:38 +0200
parents c956811fba9a
children 7c7b05a0a30e
line wrap: on
line diff
--- a/MoinMoin/util/forms.py	Sun May 29 20:40:03 2011 +0200
+++ b/MoinMoin/util/forms.py	Sun May 29 22:53:38 2011 +0200
@@ -85,3 +85,18 @@
                               error_filter,
                               required_filter, placeholder_filter, autofocus_filter])
 
+
+# other flatland stuff
+
+from flatland import AdaptationError, Scalar
+import werkzeug
+
+
+class FileStorage(Scalar):
+    """Schema element for Werkzeug FileStorage instances."""
+
+    def adapt(self, value):
+        if not isinstance(value, (type(None), werkzeug.FileStorage)):
+            raise AdaptationError
+        return value
+