diff options
author | Martin Kosek <mkosek@redhat.com> | 2012-09-04 15:49:26 +0200 |
---|---|---|
committer | Martin Kosek <mkosek@redhat.com> | 2012-09-06 14:57:07 +0200 |
commit | cfbea2a99e53dea54aaa0a1670c2bed194c4dc2c (patch) | |
tree | f719d2b5f4076ff2b7c39a0a9bab7e48442307fa | |
parent | 71f900890695dc342480664b5ec7068d2e7f230d (diff) | |
download | freeipa-cfbea2a99e53dea54aaa0a1670c2bed194c4dc2c.tar.gz freeipa-cfbea2a99e53dea54aaa0a1670c2bed194c4dc2c.tar.xz freeipa-cfbea2a99e53dea54aaa0a1670c2bed194c4dc2c.zip |
Transfer long numbers over XMLRPC
Numeric parameters in ipalib were limited by XMLRPC boundaries for
integer (2^31-1) which is too low for some LDAP attributes like DNS
SOA serial field.
Transfer numbers which are not in XMLRPC boundary as a string and not
as a number to workaround this limitation. Int parameter had to be
updated to also accept Python's long type as valid int type.
https://fedorahosted.org/freeipa/ticket/2568
-rw-r--r-- | ipalib/parameters.py | 12 | ||||
-rw-r--r-- | ipalib/rpc.py | 7 |
2 files changed, 11 insertions, 8 deletions
diff --git a/ipalib/parameters.py b/ipalib/parameters.py index e839a0e75..13f04b454 100644 --- a/ipalib/parameters.py +++ b/ipalib/parameters.py @@ -1078,7 +1078,7 @@ class Number(Param): """ if type(value) is self.type: return value - if type(value) in (unicode, int, float): + if type(value) in (unicode, int, long, float): try: return self.type(value) except ValueError: @@ -1100,8 +1100,8 @@ class Int(Number): type_error = _('must be an integer') kwargs = Param.kwargs + ( - ('minvalue', int, int(MININT)), - ('maxvalue', int, int(MAXINT)), + ('minvalue', (int, long), int(MININT)), + ('maxvalue', (int, long), int(MAXINT)), ) def __init__(self, name, *rules, **kw): @@ -1148,7 +1148,7 @@ class Int(Number): Check min constraint. """ assert type(value) in (int, long) - if value < self.minvalue or value < MININT: + if value < self.minvalue: return _('must be at least %(minvalue)d') % dict( minvalue=self.minvalue, ) @@ -1158,7 +1158,7 @@ class Int(Number): Check max constraint. """ assert type(value) in (int, long) - if value > self.maxvalue or value > MAXINT: + if value > self.maxvalue: return _('can be at most %(maxvalue)d') % dict( maxvalue=self.maxvalue, ) @@ -1491,7 +1491,7 @@ class Str(Data): """ if type(value) is self.type: return value - if type(value) in (int, float, decimal.Decimal): + if type(value) in (int, long, float, decimal.Decimal): return self.type(value) if type(value) in (tuple, list): raise ConversionError(name=self.name, index=index, diff --git a/ipalib/rpc.py b/ipalib/rpc.py index d1764e3e3..fc135f4f6 100644 --- a/ipalib/rpc.py +++ b/ipalib/rpc.py @@ -37,7 +37,8 @@ import sys import os import errno import locale -from xmlrpclib import Binary, Fault, dumps, loads, ServerProxy, Transport, ProtocolError +from xmlrpclib import (Binary, Fault, dumps, loads, ServerProxy, Transport, + ProtocolError, MININT, MAXINT) import kerberos from dns import resolver, rdatatype from dns.exception import DNSException @@ -94,9 +95,11 @@ def xml_wrap(value): if type(value) is Decimal: # transfer Decimal as a string return unicode(value) + if isinstance(value, (int, long)) and (value < MININT or value > MAXINT): + return unicode(value) if isinstance(value, DN): return str(value) - assert type(value) in (unicode, int, float, bool, NoneType) + assert type(value) in (unicode, int, long, float, bool, NoneType) return value |