1. Olemis Lang
  2. bloodhound-rpc

Commits

Olemis Lang  committed 4a5a84f

BH RPC : Product : Convert input values to unicode when creating new products via RPC

  • Participants
  • Parent commits eee9809
  • Branches bloodhound_rpc

Comments (0)

Files changed (3)

File trunk/bhrpc/product.py

View file
 from trac.perm import PermissionSystem
 from trac.resource import ResourceNotFound, Neighborhood
 from trac.util.translation import _
+from trac.util.text import to_unicode
 
 from multiproduct.env import ProductEnvironment, lookup_product_env
 from multiproduct.model import Product
 
         raise TracError(_('Product removal is not allowed!'))
 
-    def create(self, req, prefix, name, description='', owner=None):
+    def create(self, req, prefix, name, description=u'', owner=None):
         """ Create a new product . """
 
+        prefix = to_unicode(prefix)
+        name = to_unicode(name)
+        description = to_unicode(description)
         owner = owner or req.authname
         if not owner or owner == 'anonymous':
             raise TracError("Product owner must be specified")

File trunk/bhrpc/tests/product.py

View file
             self.admin.product.create(self.prefix, name, 'dupe primary key')
         self.assertEqual(-32500, test_cm.exception.faultCode)
         self.assertEquals("Product prefix='%(prefix)s' already "
-                          "exists {'name': '%(pname)s', "
-                          "'prefix': '%(prefix)s', 'owner': 'admin', "
-                          "'description': 'dupe primary key'}" % {
+                          "exists {'name': u'%(pname)s', "
+                          "'prefix': u'%(prefix)s', 'owner': 'admin', "
+                          "'description': u'dupe primary key'}" % {
                                                 'prefix' : self.prefix,
                                                 'pname' : name}, 
                           test_cm.exception.faultString)
                                       'dupe unique field')
         self.assertEqual(-32500, test_cm.exception.faultCode)
         self.assertEquals("Product name='%(pname)s' already exists"
-                          " {'name': '%(pname)s', 'prefix': '%(prefix)s', "
-                          "'owner': 'admin', 'description': 'dupe unique field'}" %
+                          " {'name': u'%(pname)s', 'prefix': u'%(prefix)s', "
+                          "'owner': 'admin', 'description': u'dupe unique field'}" %
                                 {'prefix' : self.prefix + '1',
                                  'pname' : orig_name}, 
                           test_cm.exception.faultString)

File trunk/tracrpc/tests/__init__.py

View file
         @staticmethod
         def tester_class(baseurl):
             # FIXME: Parameterize test runs to activate JSON-RPC
-            return DefaultJsonRpcTester(baseurl, skiplogin=True)
-            #return DefaultXmlRpcTester(baseurl, skiplogin=True)
+            #return DefaultJsonRpcTester(baseurl, skiplogin=True)
+            return DefaultXmlRpcTester(baseurl, skiplogin=True)
 
         def testenv_path(self, port=None):
             if port is None: