Thanks Hermann,<br><br>This still does not work for me. The pattern =
'#,##0.####' seems to have no effect on the converter. Perhaps I'm
doing something wrong, I'm posting my setup below.<br><br>This most
certainly have to be a bug in the system if you can't put 1.2345 into a
decimal field, no? If so is there a bug tracker for z3c.form where I
can post this and get it fixed?<br>
<br>#interfaces.py<br>class IFixedDecimal(IDecimal):<br> """Fixed decimal field."""<br> <br>class FixedDecimal(schema.Decimal):<br> interface.implements(<div id=":y9" class="ii gt">
IFixedDecimal)<br> <br>class ITaxLot(interface.Interface):<br>
"""A tax lot"""<br> <br> quantity = FixedDecimal(<br> title = u'Quantity',<br> required = True)<br><br>#holding.py<br>class MyDecimalDataConverter(DecimalDataConverter): <br>
"""Adapt decimal data converter"""<br> adapts(IFixedDecimal, IWidget)<div class="im"><br> # The amount of '#' after the '.' outlines the no. of decimal places<br> pattern = '#,##0.####' <br>
<br></div>#configure.zcml<br><br> <includeOverrides file="overrides.zcml" /><br><br>#overrides.zcml<br><br> <adapter factory=".holding.MyDecimalDataConverter" /></div><br><br><div class="gmail_quote">
On Thu, Feb 11, 2010 at 3:21 AM, Hermann Himmelbauer <span dir="ltr"><<a href="mailto:dusty@qwer.tk">dusty@qwer.tk</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Am Mittwoch 10 Februar 2010 17:27:09 schrieb Mats Nordgren:<br>
<div><div></div><div class="h5">> I have an interface with a decimal field. It validates fine for 1,2 and 3<br>
> fractions but if I enter a decimal with 4 fractions I get validation error<br>
> "The entered value is not a valid decimal literal."<br>
><br>
> I'm using the pypi release of bluebream and z3c.form 2.3.2.<br>
<br>
</div></div>I remember that one - quite cumbersome. Try something like this:<br>
<br>
# You should use the following interface for your forms:<br>
class IMyDecimal(IDecimal):<br>
"""Specify custom decimal interface"""<br>
<br>
# Now create a custom data converter<br>
class MyDecimalDataConverter(BaseDecimalDataConverter):<br>
"""Adapt decimal data converter"""<br>
adapts(IMyDecimal, IWidget)<br>
# The amount of '#' after the '.' outlines the no. of decimal places<br>
pattern = '#,##0.####'<br>
<br>
# And specify in overrides.zcml<br>
<adapter factory="mymodule.MyDecimalDataConverter" /><br>
<br>
This works for me.<br>
<br>
Best Regards,<br>
Hermann<br>
<font color="#888888"><br>
--<br>
<a href="mailto:hermann@qwer.tk">hermann@qwer.tk</a><br>
GPG key ID: 299893C7 (on keyservers)<br>
FP: 0124 2584 8809 EF2A DBF9 4902 64B4 D16B 2998 93C7<br>
</font></blockquote></div><br>