Decimal validation error

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
Report Content as Inappropriate

Decimal validation error

Mats Nordgren
Grok/Zope/z3cform does not let you enter a decimal with more than 3
fractional numbers without getting a validation error.

I had this problem in Bluebream and solved it with a reimplemented
Data Coverter.  I'm trying to do the same in grok but have no luck in
making it work.

Any help appreciated.


class IPriceManager(interface.Interface):
    """A price manager"""

class IPrice(interface.Interface):
    """A price"""

    date = schema.Date(
        title = u'Date')

    price = FixedDecimal(
        title = u'Price')


class IFixedDecimal(IDecimal):
    """Fixed Decimal"""

class FixedDecimal(Decimal):

class MyDecimalDataConverter(DecimalDataConverter):
    component.adapts(IFixedDecimal, IWidget)

    pattern = '#,##0.####'

    def toFieldValue(self, value):
        print '*'*100
            return self.formatter.parse(value, pattern=self.pattern)
        except NumberParseError, err:
            raise FormatterValidationError(self.errorMessage, value)



    factory="iport.schema.MyDecimalDataConverter" />


<configure xmlns=""
  <include package="grok" />
  <includeDependencies package="." />
  <grok:grok package="." />
  <includeOverrides file="overrides.zcml" />
Grok-dev mailing list
[hidden email]