missing_value doesn't work for Int fields

Bug #98479 reported by Michael R. Bernstein
2
Affects Status Importance Assigned to Milestone
Zope 3
Won't Fix
Medium
Unassigned
3.2
Won't Fix
Undecided
Unassigned
3.3
Won't Fix
Undecided
Unassigned
3.4
Won't Fix
Medium
Unassigned
zope.schema
Won't Fix
Medium
Unassigned

Bug Description

The following creates an error:

page_ordinal = zope.schema.Int(
    title = _(u'Ordinal'),
    description=_(u'Order of the pages'),
    default=0,
    missing_value=0, #don't know why this doesn't work
    )

The error is as follows:

ConfigurationError: ('Invalid value for', 'class', "(None, (<type 'int'>, <type 'long'>))")

Tags: bug core
Revision history for this message
Michael R. Bernstein (webmaven) wrote :

Changes: submitter email, classification (issue => bug)

Revision history for this message
Marius Gedminas (mgedmin) wrote :

I've looked briefly at this error. The error is raised because the defaults for min_value and max_value are both None. This fails type checking, because None is not an int or a long. When missing_value is None, type checking is skipped.

I have to admit that I do not understand the semantics of missing_value.

I think that Int should allow min_value and max_value to be None regardless of the missing_value setting. Nones should be treated as minus infinity and plus infinity respectively.

Revision history for this message
Michael R. Bernstein (webmaven) wrote :

"I have to admit that I do not understand the semantics of missing_value."

As I understand it, the value of missing_value is supposed to be used when the submitted form-field is empty. As opposed to default_value, which is supposed to pre-populate the form field.

Revision history for this message
Benji York (benji) wrote :

> = Comment - Entry #4 by webmaven on Feb 2, 2007 1:28 pm

> I think that Int should allow min_value and max_value to be None
> regardless of the missing_value setting. Nones should be treated as
> minus infinity and plus infinity respectively.

That's how it seems to me too. I looked briefly at the widget tests and couldn't figure out how to test it, so will have to look later (unless someone beats me to it, hint, hint).

Tres Seaver (tseaver)
Changed in zope.schema:
importance: Undecided → Medium
status: New → Confirmed
Tres Seaver (tseaver)
Changed in zope3:
status: Confirmed → Won't Fix
Revision history for this message
Tres Seaver (tseaver) wrote :
Changed in zope.schema:
status: Confirmed → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.