From 3ac3130fc9daf853368947b268d9af4b8a67d247 Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: Thu, 10 Feb 2011 13:29:52 -0500 Subject: Convert json strings to unicode when they are unmarshalled. This patch removes some individual work-arounds of converting strings to unicode, they only masked the problem. String values are not passed to the validator or normalizers so things like adding the realm automatically to services weren't happening. ticket 941 --- ipalib/parameters.py | 28 +--------------------------- 1 file changed, 1 insertion(+), 27 deletions(-) (limited to 'ipalib/parameters.py') diff --git a/ipalib/parameters.py b/ipalib/parameters.py index 22b03212..164374e0 100644 --- a/ipalib/parameters.py +++ b/ipalib/parameters.py @@ -1021,7 +1021,7 @@ class Int(Number): """ if type(value) in (int, long): return value - if type(value) in (str, unicode): + if type(value) is unicode: # permit floating point strings if value.find(u'.') >= 0: try: @@ -1254,14 +1254,6 @@ class Str(Data): """ if type(value) is self.type: return value - if type(value) is str: - try: - return value.decode('utf-8') - except UnicodeDecodeError: - raise ConversionError( - name=self.name, index=index, - error=ugettext(self.scalar_error) - ) if type(value) in (int, float): return self.type(value) if type(value) in (tuple, list): @@ -1385,24 +1377,6 @@ class StrEnum(Enum): type = unicode - def _convert_scalar(self, value, index=None): - """ - Convert a single scalar value. - """ - if type(value) is self.type: - return value - if type(value) is str: - try: - return value.decode('utf-8') - except UnicodeDecodeError: - raise ConversionError( - name=self.name, index=index, - error=ugettext(self.scalar_error) - ) - raise ConversionError(name=self.name, index=index, - error=ugettext(self.type_error), - ) - class List(Param): """ -- cgit