Mixing Decimal and float

B.V. bv.tryton at gmail.com
Fri Jun 4 03:29:36 EDT 2010


On Jun 2, 10:35 pm, I V <ivle... at gmail.com> wrote:
> On Wed, 02 Jun 2010 05:17:11 -0700, B.V. wrote:
> > But trying to be open to other languages, the server implements also an
> > XMLRPC interface (and also a JSONRPC-like interface). That's the key
> > point: Decimal is python specific. So in an application, you can't rely
> > on the value received from a client, because depending on the protocol,
> > the type of the value is different. So the idea was to create a class
> > that can behave like a Decimal or a float depending on the context, and
> > set xmlrpclib.Unmarshaller.dispatch["double"] to a function that return
> > a Float instance.
>
> Looking at the Tryton docs, it seems that it already supports field types
> that can't be directly represented in XMLRPC or JSON, like BigInteger or
> Selection. How are these serialized over the non-python RPC mechanisms?
> Could you not do the same for Decimals?
>

That's what was done first, it works for data sent by the server. But
when the server receives data, it's always float. How guess that a
float has to stay a float or became a Decimal ?
Well, Selection are just strings, no problem over any RPC mechanisms.
For the BigInteger, good question. Maybe there's a problem with,
because AFAIK it's not used in any of the classes. I think I give it a
try and who knows, maybe find a new bug ...

B.



More information about the Python-list mailing list