• Tatuya Kamada's avatar
    ERP5Catalog: Fix UnicodeDecodeError on non ascii catalog search when the inituser name is unicode · ba927bc2
    Tatuya Kamada authored
    Zope4 inituser is decoded by decode('utf-8') on Zope startup and it is unicode on python2,
    therefore it raises UnicodeDecodeError when searching non ascii charater on catalog.
    
      Traceback (most recent call last):
      File "<portal_components/test.erp5.testERP5Catalog>", line 4144, in testSearchNonAsciiWithTheInitUser
        person_module.searchFolder(title=person_title)]
      File "./erp5/product/ERP5Type/Core/Folder.py", line 452, in searchFolder
        return self.portal_catalog.searchResults(**kw)
      File "./erp5/product/ERP5Catalog/CatalogTool.py", line 819, in searchResults
        return ZCatalog.searchResults(self, sql_catalog_id=catalog_id, **kw)
      File "./erp5/product/ZSQLCatalog/ZSQLCatalog.py", line 1070, in searchResults
        return catalog.searchResults(REQUEST, **kw)
      File "./erp5/product/ZSQLCatalog/SQLCatalog.py", line 2362, in searchResults
        **kw
      File "./erp5/product/ZSQLCatalog/SQLCatalog.py", line 2326, in queryResults
        **kw
      File "./erp5/product/ZSQLCatalog/SQLCatalog.py", line 2214, in buildSQLQuery
        only_group_columns,
      File "./erp5/product/ZSQLCatalog/SQLExpression.py", line 397, in asSQLExpressionDict
        'where_expression': self.getWhereExpression(),
      File "./erp5/product/ZSQLCatalog/SQLExpression.py", line 298, in getWhereExpression
        result = self.sql_expression_list[0].getWhereExpression()
      File "./erp5/product/ZSQLCatalog/SQLExpression.py", line 303, in getWhereExpression
        result = '(%s)' % (operator.join(x.getWhereExpression() for x in self.sql_expression_list), )
      UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 25: ordinal not in range(128)
    ba927bc2
CatalogTool.py 62 KB