Re: [Django] #17147: DecimalField causes inline formsets to disappear

2013-01-26 Thread Django
#17147: DecimalField causes inline formsets to disappear
---+-
 Reporter:  leith.john@…   |Owner:  jcd
 Type:  Bug|   Status:  closed
Component:  Forms  |  Version:  1.2
 Severity:  Normal |   Resolution:  needsinfo
 Keywords:  admin formset  | Triage Stage:  Accepted
Has patch:  0  |  Needs documentation:  0
  Needs tests:  0  |  Patch needs improvement:  0
Easy pickings:  0  |UI/UX:  0
---+-
Changes (by claudep):

 * status:  assigned => closed
 * resolution:   => needsinfo


Comment:

 Closed as needinfo until a test case can demonstrate the issue.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Django] #17147: DecimalField causes inline formsets to disappear

2011-11-12 Thread Django
#17147: DecimalField causes inline formsets to disappear
---+
 Reporter:  leith.john@…   |Owner:  jcd
 Type:  Bug|   Status:  assigned
Component:  Forms  |  Version:  1.2
 Severity:  Normal |   Resolution:
 Keywords:  admin formset  | Triage Stage:  Accepted
Has patch:  0  |  Needs documentation:  0
  Needs tests:  0  |  Patch needs improvement:  0
Easy pickings:  0  |UI/UX:  0
---+

Comment (by anonymous):

 I've tried to produce a test case that would be helpful for you, but after
 creating arbitrary models to simulate the problem everything was working
 perfectly. I think i must conclude that the problem is somewhere in my
 code then (or the satchmo base that i'm using). I'll check it out and let
 you know if i can find anything on it.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #17147: DecimalField causes inline formsets to disappear

2011-11-12 Thread Django
#17147: DecimalField causes inline formsets to disappear
---+
 Reporter:  leith.john@…   |Owner:  jcd
 Type:  Bug|   Status:  assigned
Component:  Forms  |  Version:  1.2
 Severity:  Normal |   Resolution:
 Keywords:  admin formset  | Triage Stage:  Accepted
Has patch:  0  |  Needs documentation:  0
  Needs tests:  0  |  Patch needs improvement:  0
Easy pickings:  0  |UI/UX:  0
---+
Changes (by jcd):

 * owner:  nobody => jcd
 * status:  new => assigned


Comment:

 I'm having trouble reproducing a text input that doesn't trigger a
 validation error.

 The decimal module has certain flags that occur in non-normal
 circumstances.  The flags raise exceptions (of the same name) if "traps"
 are set for them.  By default, traps are set for InvalidOperation,
 DivisionByZero and Overflow.  All of the flags are subclasses of
 DecimalException.

 InvalidOperation is what happens when a string is passed to Decimal that
 doesn't represent a number.  So I thought perhaps the trap was being
 turned off on InvalidOperation.  But without the trap, an InvalidOperation
 produces a Decimal('NaN') as the documentation specifies, and
 Decimal('NaN') triggers the same ValidationError, so that isn't the issue.

 Overflow only seems to occur when math happens, not when numbers are
 instantiated from strings.  Decimal will happily create an object for me
 with an exponent greater than emax, but if I try to add to it, I get an
 Overflow
 {{{
 >>> import decimal
 >>> decimal.getcontext()
 >>> import decimal
 >>> decimal.getcontext()
 Context(prec=28, rounding=ROUND_HALF_EVEN, Emin=-9,
 Emax=9, capitals=1, flags=[], traps=[Overflow, DivisionByZero,
 InvalidOperation])
 >>> decimal.getcontext().Emax=10
 >>> d = decimal.Decimal('1e9')
 >>> d
 Decimal('1E+9')
 >>> d * 100
 Traceback (most recent call last):
   ...
 decimal.Overflow: above Emax
 >>> d = decimal.Decimal('1E11')
 >>> d
 Decimal('1E+11')
 >>>
 }}}

 It seems as though InvalidOperation is the only kind of DecimalException
 that you would hit when instantiating a Decimal object from a string.
 Thus, it's hard to see how you would not hit the ValidationError.  A few
 questions for the reporter of this bug:

 1. What input is causing this error?
 2. Does your application alter the decimal context in any way?
 3. What is the result of {{{ print decimal.getcontext() }}} right before
 the form is validated?
 4. Is your form doing anything special with the DecimalField?  Custom
 validation or cleaning?

 Thanks.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #17147: DecimalField causes inline formsets to disappear

2011-11-12 Thread Django
#17147: DecimalField causes inline formsets to disappear
---+
 Reporter:  leith.john@…   |Owner:  nobody
 Type:  Bug|   Status:  new
Component:  Forms  |  Version:  1.2
 Severity:  Normal |   Resolution:
 Keywords:  admin formset  | Triage Stage:  Accepted
Has patch:  0  |  Needs documentation:  0
  Needs tests:  0  |  Patch needs improvement:  0
Easy pickings:  0  |UI/UX:  0
---+
Changes (by julien):

 * stage:  Unreviewed => Accepted


Comment:

 Accepting at least on the basis that
 `models.fields.DecimalField.to_python()` and
 `form.fields.DecimalField.to_python()` should have a more consolidated way
 of handling exceptions. Again, a test demonstrating an actual use case
 would also be useful.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #17147: DecimalField causes inline formsets to disappear

2011-11-07 Thread Django
#17147: DecimalField causes inline formsets to disappear
---+--
 Reporter:  leith.john@…   |Owner:  nobody
 Type:  Bug|   Status:  new
Component:  Forms  |  Version:  1.2
 Severity:  Normal |   Resolution:
 Keywords:  admin formset  | Triage Stage:  Unreviewed
Has patch:  0  |  Needs documentation:  0
  Needs tests:  0  |  Patch needs improvement:  0
Easy pickings:  0  |UI/UX:  0
---+--
Changes (by julien):

 * needs_docs:   => 0
 * needs_tests:   => 0
 * needs_better_patch:   => 0


Comment:

 Raising a `ValidationError` is actually the way to return an error message
 to the user.

 Note that `models.fields.DecimalField.to_python()` catches a different
 error (`decimal.InvalidOperation`). Maybe the form field should also catch
 `decimal.InvalidOperation` instead of `DecimalException`.

 Could you please provide a minimal test case reproducing the problem
 you're facing?

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



[Django] #17147: DecimalField causes inline formsets to disappear

2011-11-02 Thread Django
#17147: DecimalField causes inline formsets to disappear
--+---
 Reporter:  leith.john@…  |  Owner:  nobody
 Type:  Bug   | Status:  new
Component:  Forms |Version:  1.2
 Severity:  Normal|   Keywords:  admin formset
 Triage Stage:  Unreviewed|  Has patch:  0
Easy pickings:  0 |  UI/UX:  0
--+---
 I have a client who typed non-numeric characters in a DecimalField (for
 price). When he saved the form returned but the inline formset had
 vanished.

 I think when the characters came to the DecimalField, it raised an
 exception which caused the inline to crash and thus disappear.

 in django.forms.fields:

 {{{
 def to_python(self, value):
 """
 Validates that the input is a decimal number. Returns a Decimal
 instance. Returns None for empty values. Ensures that there are no
 more
 than max_digits in the number, and no more than decimal_places
 digits
 after the decimal point.
 """
 if value in validators.EMPTY_VALUES:
 return None
 if self.localize:
 value = formats.sanitize_separators(value)
 value = smart_str(value).strip()
 try:
 value = Decimal(value)
 except DecimalException:
 # >>> i think this is the culprit, should it throw
 validationerrors here?
 # about line 292
 raise ValidationError(self.error_messages['invalid'])
 return value
 }}}

 I know my client shouldn't have put characters in there of course, but
 it's very possible to accidentally put in wrong data in a form field. I
 think the decimal field should display an error rather than raising an
 exception at this point.

 I'm using this for now:

 {{{
 class SafeDecimalField(forms.DecimalField):
 def to_python(self, value):
 try:
 return super(SafeDecimalField, self).to_python(value)
 except Exception, ex:
 return Decimal("0.0")
 }}}

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.