On Jun 23, 2007, at 6:38 AM, Christian Zagrodnick wrote:

Log message for revision 76975:
FileWidget tries to be smarter about not deleting the currently stored content when the user did not upload a new file.

...

Modified: zope.app.form/trunk/src/zope/app/form/browser/textwidgets.py
===================================================================
--- zope.app.form/trunk/src/zope/app/form/browser/textwidgets.py 2007-06-23 10:25:23 UTC (rev 76974) +++ zope.app.form/trunk/src/zope/app/form/browser/textwidgets.py 2007-06-23 10:38:37 UTC (rev 76975)
@@ -475,6 +475,11 @@

     def _toFieldValue(self, input):
         if input is None or input == '':
+ # There was no input. With File-Upload this usually means that the + # value should *not* change. Let's try to get the old value.
+            content = self.context.context
+            if self.context.interface.providedBy(content):
+                return self.context.get(content)
             return self.context.missing_value
         try:
             seek = input.seek

Hey. This has a couple of bugs, IMO. It might also be a misfeature, but I'm less sure about that.

First, "return self.context.get(content)" assumes that this widget will be used on an edit form (not true for us).

Second, "if self.context.interface.providedBy(content):" assumes that the schema field is part of an interface (not true for us).

Neither of these are valid assumptions generally for a form field, IMO.

I'm also not sure about the semantics. Shouldn't this be handled more at the form level? I can see why you want to do this here, but it seems pretty gray, and I'm not sure how to solve the bugs in a sane and reliable way.

I agree that this is a tricky problem, and it would be nice to solve it, but your solution is not correct for a generic form widget. The only suggestion I have ATM is to revert this, unfortunately, but I welcome other approaches that solve the issues I raised.

(I'm reverting to zope.app.form 3.4.0b1 for now)

Gary

_______________________________________________
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com

Reply via email to