[Zope-dev] z3c.form - extraction from sequence widget

Martin Aspeli optilude at gmx.net
Wed Aug 27 18:07:21 EDT 2008


Hi,

In z3c.form.widget.SequenceWidget, we have:

     def extract(self, default=interfaces.NOVALUE):
         """See z3c.form.interfaces.IWidget."""
         if (self.name not in self.request and
             self.name+'-empty-marker' in self.request):
             return []
         value = self.request.get(self.name, default)
         if value != default:
             for token in value:
                 if token == self.noValueToken:
                     continue
                 try:
                     self.terms.getTermByToken(token)
                 except LookupError:
                     return default
         return value

This means that if the request contains the empty-marker only (no 
selection was made) for a checkbox widget (say), then the return value 
is [], rather than default (NOVALUE).

Is that a bug? I have a custom checkbox widget derived from the standard 
checkbox widget, (z3c.formwidget.query, in fact), and I never get any 
"required missing" exceptions, even when I untick all the checkboxes and 
click OK.

Am I missing something?

Cheers,
Martin

-- 
Author of `Professional Plone Development`, a book for developers who
want to work with Plone. See http://martinaspeli.net/plone-book



More information about the Zope-Dev mailing list