[Zope-dev] z3c.form - creating a file upload widget

Dan Korostelev nadako at gmail.com
Thu Mar 12 11:35:37 EDT 2009


2009/3/12 Stephan Richter <srichter at cosmos.phy.tufts.edu>:
> On Thursday 12 March 2009, Martin Aspeli wrote:
>> I'm writing a custom file widget for z3c.form that works like the
>> Archetypes file widget that Plone uses and the formlib widget in
>> collective.namedfile. That is, after you've uploaded a file once, you're
>> given a radio button to decide whether to upload a new file, or leave
>> the existing file in place.
>>
>> I can't quite figure out how to do this, though. I've tried to override
>> the extract() method on the widget to look in the request for the
>> special marker that says "user chose not to change the file". However, I
>> don't know what to return. If I return NOVALUE, then validation fails
>> (if the field is required). If I try to look up the field value from the
>> data manager and return it, it ends up setting the field back on itself,
>> which is wasteful.
>
> All great questions and I am not sure I have good answers. I think you want
> a "NONEWVALUE" or so marker and have the validator honor it correctly.
>
> If you make a proposal to enrich the API, I'll probably agree to it. :-)

Just to note, there's already the NOT_CHANGED constant in z3c.form.interfaces.

-- 
WBR, Dan Korostelev


More information about the Zope-Dev mailing list