Hi,

The attached patch should fix this bug:
https://fedorahosted.org/freeipa/ticket/657

The StrEnum class has been modified to accept str value and convert
it into unicode. This is to fix encoding issue on F14.

--
Endi S. Dewata
From 0e7461f70742b7b14fd3dfe9aebf451bd21e1252 Mon Sep 17 00:00:00 2001
From: Endi S. Dewata <[email protected]>
Date: Thu, 13 Jan 2011 12:42:16 -0500
Subject: [PATCH] Support for str in StrEnum.

The StrEnum class has been modified to accept str value and convert
it into unicode. This is to fix encoding issue on F14.
---
 ipalib/parameters.py |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/ipalib/parameters.py b/ipalib/parameters.py
index 128c8a463ee2969287d8c2a007a8901c27b24216..78eacde25be03ec3280bc4972ecb1308b80b348f 100644
--- a/ipalib/parameters.py
+++ b/ipalib/parameters.py
@@ -1384,6 +1384,24 @@ 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):
     """
-- 
1.7.3.4

_______________________________________________
Freeipa-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to