Re: [Freeipa-devel] [PATCH] 091 Improve long integer type validation
On Fri, 2011-07-15 at 17:26 -0400, Rob Crittenden wrote: Martin Kosek wrote: Passing a number of long type to IPA Int parameter invokes user-unfriendly error message about incompatible types. This patch improves Int parameter with user understandable message along with maximum value he can pass. https://fedorahosted.org/freeipa/ticket/1346 nack. We need to limit Int to 32-bit values because that is what XML-RPC supports. So if maxvalue isn't set we need to compare against MAXINT and not sys.maxint. rob You are right. Sending a fixed patch. Martin From ada8023da76e12139593559ddc9b78865faf26bd Mon Sep 17 00:00:00 2001 From: Martin Kosek mko...@redhat.com Date: Thu, 14 Jul 2011 09:14:07 +0200 Subject: [PATCH] Improve long integer type validation Passing a number of long type to IPA Int parameter invokes user-unfriendly error message about incompatible types. This patch improves Int parameter with user understandable message along with maximum value he can pass. https://fedorahosted.org/freeipa/ticket/1346 --- ipalib/parameters.py | 24 1 files changed, 24 insertions(+), 0 deletions(-) diff --git a/ipalib/parameters.py b/ipalib/parameters.py index da3b05cf731578a70f32f5b3d922c670c74cb898..982b192a7776f575ac97e7ed2178c9910f0915e4 100644 --- a/ipalib/parameters.py +++ b/ipalib/parameters.py @@ -1066,6 +1066,30 @@ class Int(Number): maxvalue=self.maxvalue, ) +def _validate_scalar(self, value, index=None): +if type(value) is long: +# too big number for int type to hold +if self.maxvalue is not None: +raise ValidationError( +name=self.name, +value=value, +index=index, +error=_('can be at most %(maxvalue)d') % dict( +maxvalue=self.maxvalue, +) +) +else: +raise ValidationError( +name=self.name, +value=value, +index=index, +error=_('can be at most %(maxvalue)d') % dict( +maxvalue=MAXINT, +) +) +super(Int, self)._validate_scalar(value, index) + + class Float(Number): A parameter for floating-point values (stored in the ``float`` type). -- 1.7.6 ___ Freeipa-devel mailing list Freeipa-devel@redhat.com https://www.redhat.com/mailman/listinfo/freeipa-devel
Re: [Freeipa-devel] [PATCH] 091 Improve long integer type validation
Martin Kosek wrote: On Fri, 2011-07-15 at 17:26 -0400, Rob Crittenden wrote: Martin Kosek wrote: Passing a number of long type to IPA Int parameter invokes user-unfriendly error message about incompatible types. This patch improves Int parameter with user understandable message along with maximum value he can pass. https://fedorahosted.org/freeipa/ticket/1346 nack. We need to limit Int to 32-bit values because that is what XML-RPC supports. So if maxvalue isn't set we need to compare against MAXINT and not sys.maxint. rob You are right. Sending a fixed patch. Martin ACK ___ Freeipa-devel mailing list Freeipa-devel@redhat.com https://www.redhat.com/mailman/listinfo/freeipa-devel
Re: [Freeipa-devel] [PATCH] 091 Improve long integer type validation
On Mon, 2011-07-18 at 09:43 -0400, Rob Crittenden wrote: Martin Kosek wrote: On Fri, 2011-07-15 at 17:26 -0400, Rob Crittenden wrote: Martin Kosek wrote: Passing a number of long type to IPA Int parameter invokes user-unfriendly error message about incompatible types. This patch improves Int parameter with user understandable message along with maximum value he can pass. https://fedorahosted.org/freeipa/ticket/1346 nack. We need to limit Int to 32-bit values because that is what XML-RPC supports. So if maxvalue isn't set we need to compare against MAXINT and not sys.maxint. rob You are right. Sending a fixed patch. Martin ACK Pushed to master, ipa-2-0. Martin ___ Freeipa-devel mailing list Freeipa-devel@redhat.com https://www.redhat.com/mailman/listinfo/freeipa-devel
Re: [Freeipa-devel] [PATCH] 091 Improve long integer type validation
On 07/15/2011 05:26 PM, Rob Crittenden wrote: Martin Kosek wrote: Passing a number of long type to IPA Int parameter invokes user-unfriendly error message about incompatible types. This patch improves Int parameter with user understandable message along with maximum value he can pass. https://fedorahosted.org/freeipa/ticket/1346 nack. We need to limit Int to 32-bit values because that is what XML-RPC supports. So if maxvalue isn't set we need to compare against MAXINT and not sys.maxint. rob ___ Freeipa-devel mailing list Freeipa-devel@redhat.com https://www.redhat.com/mailman/listinfo/freeipa-devel Is this the wrong forum to point out how wrong XML-RPC is in limiting things to 32 bit values? ___ Freeipa-devel mailing list Freeipa-devel@redhat.com https://www.redhat.com/mailman/listinfo/freeipa-devel
Re: [Freeipa-devel] [PATCH] 091 Improve long integer type validation
Martin Kosek wrote: Passing a number of long type to IPA Int parameter invokes user-unfriendly error message about incompatible types. This patch improves Int parameter with user understandable message along with maximum value he can pass. https://fedorahosted.org/freeipa/ticket/1346 nack. We need to limit Int to 32-bit values because that is what XML-RPC supports. So if maxvalue isn't set we need to compare against MAXINT and not sys.maxint. rob ___ Freeipa-devel mailing list Freeipa-devel@redhat.com https://www.redhat.com/mailman/listinfo/freeipa-devel
[Freeipa-devel] [PATCH] 091 Improve long integer type validation
Passing a number of long type to IPA Int parameter invokes user-unfriendly error message about incompatible types. This patch improves Int parameter with user understandable message along with maximum value he can pass. https://fedorahosted.org/freeipa/ticket/1346 From a1f70026b2424cf07a0b497c1edd2e9134dcfdfc Mon Sep 17 00:00:00 2001 From: Martin Kosek mko...@redhat.com Date: Thu, 14 Jul 2011 09:14:07 +0200 Subject: [PATCH] Improve long integer type validation Passing a number of long type to IPA Int parameter invokes user-unfriendly error message about incompatible types. This patch improves Int parameter with user understandable message along with maximum value he can pass. https://fedorahosted.org/freeipa/ticket/1346 --- ipalib/parameters.py | 25 + 1 files changed, 25 insertions(+), 0 deletions(-) diff --git a/ipalib/parameters.py b/ipalib/parameters.py index da3b05cf731578a70f32f5b3d922c670c74cb898..a20d0e6d253644f5b2e83386e34b1e0a57006ad9 100644 --- a/ipalib/parameters.py +++ b/ipalib/parameters.py @@ -100,6 +100,7 @@ a more detailed description for clarity. import re +import sys from types import NoneType from util import make_repr from text import _ as ugettext @@ -1066,6 +1067,30 @@ class Int(Number): maxvalue=self.maxvalue, ) +def _validate_scalar(self, value, index=None): +if type(value) is long: +# too big number for int type to hold +if self.maxvalue is not None: +raise ValidationError( +name=self.name, +value=value, +index=index, +error=_('can be at most %(maxvalue)d') % dict( +maxvalue=self.maxvalue, +) +) +else: +raise ValidationError( +name=self.name, +value=value, +index=index, +error=_('can be at most %(maxvalue)d') % dict( +maxvalue=sys.maxint, +) +) +super(Int, self)._validate_scalar(value, index) + + class Float(Number): A parameter for floating-point values (stored in the ``float`` type). -- 1.7.6 ___ Freeipa-devel mailing list Freeipa-devel@redhat.com https://www.redhat.com/mailman/listinfo/freeipa-devel