cloudera / hue

Open source SQL Query Assistant service for Databases/Warehouses
https://cloudera.com
Apache License 2.0
1.17k stars 367 forks source link

banner_top_html doesn't support non-ascii text #228

Closed vls closed 9 years ago

vls commented 9 years ago

Hi, I was able to input chinese to banner_top_html setting in cloudera manager, and the actual running hue.ini is correct, and it's in UTF-8 encoding。 image

But when I visit hue main page, I got this error:

Traceback (most recent call last):
  File "/usr/lib/hue/desktop/core/src/desktop/lib/wsgiserver.py", line 1198, in communicate
    req.respond()
  File "/usr/lib/hue/desktop/core/src/desktop/lib/wsgiserver.py", line 568, in respond
    self._respond()
  File "/usr/lib/hue/desktop/core/src/desktop/lib/wsgiserver.py", line 580, in _respond
    response = self.wsgi_app(self.environ, self.start_response)
  File "/usr/lib/hue/build/env/lib/python2.7/site-packages/Django-1.6.10-py2.7.egg/django/core/handlers/wsgi.py", line 206, in __call__
    response = self.get_response(request)
  File "/usr/lib/hue/build/env/lib/python2.7/site-packages/Django-1.6.10-py2.7.egg/django/core/handlers/base.py", line 194, in get_response
    response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
  File "/usr/lib/hue/build/env/lib/python2.7/site-packages/Django-1.6.10-py2.7.egg/django/core/handlers/base.py", line 236, in handle_uncaught_exception
    return callback(request, **param_dict)
  File "/usr/lib/hue/desktop/core/src/desktop/views.py", line 304, in serve_500_error
    return render("500.mako", request, {'traceback': traceback.extract_tb(exc_info[2])})
  File "/usr/lib/hue/desktop/core/src/desktop/lib/django_util.py", line 225, in render
    **kwargs)
  File "/usr/lib/hue/desktop/core/src/desktop/lib/django_util.py", line 146, in _render_to_response
    return django_mako.render_to_response(template, *args, **kwargs)
  File "/usr/lib/hue/desktop/core/src/desktop/lib/django_mako.py", line 125, in render_to_response
    return HttpResponse(render_to_string(template_name, data_dictionary), **kwargs)
  File "/usr/lib/hue/desktop/core/src/desktop/lib/django_mako.py", line 114, in render_to_string_normal
    result = template.render(**data_dict)
  File "/usr/lib/hue/build/env/lib/python2.7/site-packages/Mako-0.8.1-py2.7.egg/mako/template.py", line 443, in render
    return runtime._render(self, self.callable_, args, data)
  File "/usr/lib/hue/build/env/lib/python2.7/site-packages/Mako-0.8.1-py2.7.egg/mako/runtime.py", line 786, in _render
    **_kwargs_for_callable(callable_, data))
  File "/usr/lib/hue/build/env/lib/python2.7/site-packages/Mako-0.8.1-py2.7.egg/mako/runtime.py", line 818, in _render_context
    _exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
  File "/usr/lib/hue/build/env/lib/python2.7/site-packages/Mako-0.8.1-py2.7.egg/mako/runtime.py", line 844, in _exec_template
    callable_(context, *args, **kwargs)
  File "/tmp/tmp9S5muz/desktop/500.mako.py", line 39, in render_body
    __M_writer(unicode( commonheader(_('Error'), "", user) ))
  File "/usr/lib/hue/desktop/core/src/desktop/views.py", line 375, in commonheader
    'is_demo': desktop.conf.DEMO_ENABLED.get()
  File "/usr/lib/hue/desktop/core/src/desktop/lib/django_mako.py", line 114, in render_to_string_normal
    result = template.render(**data_dict)
  File "/usr/lib/hue/build/env/lib/python2.7/site-packages/Mako-0.8.1-py2.7.egg/mako/template.py", line 443, in render
    return runtime._render(self, self.callable_, args, data)
  File "/usr/lib/hue/build/env/lib/python2.7/site-packages/Mako-0.8.1-py2.7.egg/mako/runtime.py", line 786, in _render
    **_kwargs_for_callable(callable_, data))
  File "/usr/lib/hue/build/env/lib/python2.7/site-packages/Mako-0.8.1-py2.7.egg/mako/runtime.py", line 818, in _render_context
    _exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
  File "/usr/lib/hue/build/env/lib/python2.7/site-packages/Mako-0.8.1-py2.7.egg/mako/runtime.py", line 844, in _exec_template
    callable_(context, *args, **kwargs)
  File "/tmp/tmp9S5muz/desktop/common_header.mako.py", line 248, in render_body
    __M_writer(unicode( conf.CUSTOM.BANNER_TOP_HTML.get() ))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 0: ordinal not in range(128)

Please fix this bug, Thank you!

enricoberti commented 9 years ago

We suggest you to use the html unicode escapes in there instead of the symbols, that should work fine!

Let me know if you need further help :)

E.

On 28 Aug 2015, at 10:19, Liang Zhaohao notifications@github.com wrote:

Hi, I was able to input chinese to banner_top_html setting in cloudera manager, and the actual running hue.ini is correct, and it's in UTF-8 encoding。 https://cloud.githubusercontent.com/assets/490272/9542035/f9ae649c-4d9f-11e5-9aa7-ecfbe8f86dd3.png But when I visit hue main page, I got this error:

Traceback (most recent call last): File "/usr/lib/hue/desktop/core/src/desktop/lib/wsgiserver.py", line 1198, in communicate req.respond() File "/usr/lib/hue/desktop/core/src/desktop/lib/wsgiserver.py", line 568, in respond self._respond() File "/usr/lib/hue/desktop/core/src/desktop/lib/wsgiserver.py", line 580, in _respond response = self.wsgi_app(self.environ, self.start_response) File "/usr/lib/hue/build/env/lib/python2.7/site-packages/Django-1.6.10-py2.7.egg/django/core/handlers/wsgi.py", line 206, in call response = self.get_response(request) File "/usr/lib/hue/build/env/lib/python2.7/site-packages/Django-1.6.10-py2.7.egg/django/core/handlers/base.py", line 194, in get_response response = self.handle_uncaught_exception(request, resolver, sys.exc_info()) File "/usr/lib/hue/build/env/lib/python2.7/site-packages/Django-1.6.10-py2.7.egg/django/core/handlers/base.py", line 236, in handle_uncaught_exception return callback(request, param_dict) File "/usr/lib/hue/desktop/core/src/desktop/views.py", line 304, in serve_500_error return render("500.mako", request, {'traceback': traceback.extract_tb(exc_info[2])}) File "/usr/lib/hue/desktop/core/src/desktop/lib/django_util.py", line 225, in render _kwargs) File "/usr/lib/hue/desktop/core/src/desktop/lib/django_util.py", line 146, in _render_to_response return django_mako.render_to_response(template, args, *_kwargs) File "/usr/lib/hue/desktop/core/src/desktop/lib/django_mako.py", line 125, in render_to_response return HttpResponse(render_to_string(template_name, data_dictionary), kwargs) File "/usr/lib/hue/desktop/core/src/desktop/lib/django_mako.py", line 114, in render_to_string_normal result = template.render(data_dict) File "/usr/lib/hue/build/env/lib/python2.7/site-packages/Mako-0.8.1-py2.7.egg/mako/template.py", line 443, in render return runtime.render(self, self.callable, args, data) File "/usr/lib/hue/build/env/lib/python2.7/site-packages/Mako-0.8.1-py2.7.egg/mako/runtime.py", line 786, in _render *_kwargs_forcallable(callable, data)) File "/usr/lib/hue/build/env/lib/python2.7/site-packages/Mako-0.8.1-py2.7.egg/mako/runtime.py", line 818, in _render_context _exec_template(inherit, lclcontext, args=args, kwargs=kwargs) File "/usr/lib/hue/build/env/lib/python2.7/site-packages/Mako-0.8.1-py2.7.egg/mako/runtime.py", line 844, in _exectemplate callable(context, _args, _kwargs) File "/tmp/tmp9S5muz/desktop/500.mako.py", line 39, in render_body __Mwriter(unicode( commonheader(('Error'), "", user) )) File "/usr/lib/hue/desktop/core/src/desktop/views.py", line 375, in commonheader 'is_demo': desktop.conf.DEMO_ENABLED.get() File "/usr/lib/hue/desktop/core/src/desktop/lib/django_mako.py", line 114, in render_to_string_normal result = template.render(data_dict) File "/usr/lib/hue/build/env/lib/python2.7/site-packages/Mako-0.8.1-py2.7.egg/mako/template.py", line 443, in render return runtime.render(self, self.callable, args, data) File "/usr/lib/hue/build/env/lib/python2.7/site-packages/Mako-0.8.1-py2.7.egg/mako/runtime.py", line 786, in _render *_kwargs_forcallable(callable, data)) File "/usr/lib/hue/build/env/lib/python2.7/site-packages/Mako-0.8.1-py2.7.egg/mako/runtime.py", line 818, in _render_context _exec_template(inherit, lclcontext, args=args, kwargs=kwargs) File "/usr/lib/hue/build/env/lib/python2.7/site-packages/Mako-0.8.1-py2.7.egg/mako/runtime.py", line 844, in _exectemplate callable(context, _args, _kwargs) File "/tmp/tmp9S5muz/desktop/common_header.mako.py", line 248, in render_body __M_writer(unicode( conf.CUSTOM.BANNER_TOP_HTML.get() )) UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 0: ordinal not in range(128) Please fix this bug, Thank you!

— Reply to this email directly or view it on GitHub https://github.com/cloudera/hue/issues/228.

vls commented 9 years ago

I tried many encode form for 中文 u'\u4e2d\u6587' '\u4e2d\u6587' \u4e2d\u6587 中文 ...

but it's all failed to show correctly.

Please help with an example or document refer link.

Thanks

Liang Zhaohao

2015-08-28 16:24 GMT+08:00 Enrico Berti notifications@github.com:

We suggest you to use the html unicode escapes in there instead of the symbols, that should work fine!

Let me know if you need further help :)

E.

On 28 Aug 2015, at 10:19, Liang Zhaohao notifications@github.com wrote:

Hi, I was able to input chinese to banner_top_html setting in cloudera manager, and the actual running hue.ini is correct, and it's in UTF-8 encoding。 < https://cloud.githubusercontent.com/assets/490272/9542035/f9ae649c-4d9f-11e5-9aa7-ecfbe8f86dd3.png

But when I visit hue main page, I got this error:

Traceback (most recent call last): File "/usr/lib/hue/desktop/core/src/desktop/lib/wsgiserver.py", line 1198, in communicate req.respond() File "/usr/lib/hue/desktop/core/src/desktop/lib/wsgiserver.py", line 568, in respond self._respond() File "/usr/lib/hue/desktop/core/src/desktop/lib/wsgiserver.py", line 580, in _respond response = self.wsgi_app(self.environ, self.start_response) File "/usr/lib/hue/build/env/lib/python2.7/site-packages/Django-1.6.10-py2.7.egg/django/core/handlers/wsgi.py", line 206, in call response = self.get_response(request) File "/usr/lib/hue/build/env/lib/python2.7/site-packages/Django-1.6.10-py2.7.egg/django/core/handlers/base.py", line 194, in get_response response = self.handle_uncaught_exception(request, resolver, sys.exc_info()) File "/usr/lib/hue/build/env/lib/python2.7/site-packages/Django-1.6.10-py2.7.egg/django/core/handlers/base.py", line 236, in handle_uncaught_exception return callback(request, param_dict) File "/usr/lib/hue/desktop/core/src/desktop/views.py", line 304, in serve_500_error return render("500.mako", request, {'traceback': traceback.extract_tb(exc_info[2])}) File "/usr/lib/hue/desktop/core/src/desktop/lib/django_util.py", line 225, in render _kwargs) File "/usr/lib/hue/desktop/core/src/desktop/lib/django_util.py", line 146, in _render_to_response return django_mako.render_to_response(template, args, *_kwargs) File "/usr/lib/hue/desktop/core/src/desktop/lib/django_mako.py", line 125, in render_to_response return HttpResponse(render_to_string(template_name, data_dictionary), kwargs) File "/usr/lib/hue/desktop/core/src/desktop/lib/django_mako.py", line 114, in render_to_string_normal result = template.render(data_dict) File "/usr/lib/hue/build/env/lib/python2.7/site-packages/Mako-0.8.1-py2.7.egg/mako/template.py", line 443, in render return runtime.render(self, self.callable, args, data) File "/usr/lib/hue/build/env/lib/python2.7/site-packages/Mako-0.8.1-py2.7.egg/mako/runtime.py", line 786, in _render *_kwargs_forcallable(callable, data)) File "/usr/lib/hue/build/env/lib/python2.7/site-packages/Mako-0.8.1-py2.7.egg/mako/runtime.py", line 818, in _render_context _exec_template(inherit, lclcontext, args=args, kwargs=kwargs) File "/usr/lib/hue/build/env/lib/python2.7/site-packages/Mako-0.8.1-py2.7.egg/mako/runtime.py", line 844, in _exectemplate callable(context, _args, _kwargs) File "/tmp/tmp9S5muz/desktop/500.mako.py", line 39, in render_body __Mwriter(unicode( commonheader(('Error'), "", user) )) File "/usr/lib/hue/desktop/core/src/desktop/views.py", line 375, in commonheader 'is_demo': desktop.conf.DEMO_ENABLED.get() File "/usr/lib/hue/desktop/core/src/desktop/lib/django_mako.py", line 114, in render_to_string_normal result = template.render(data_dict) File "/usr/lib/hue/build/env/lib/python2.7/site-packages/Mako-0.8.1-py2.7.egg/mako/template.py", line 443, in render return runtime.render(self, self.callable, args, data) File "/usr/lib/hue/build/env/lib/python2.7/site-packages/Mako-0.8.1-py2.7.egg/mako/runtime.py", line 786, in _render *_kwargs_forcallable(callable, data)) File "/usr/lib/hue/build/env/lib/python2.7/site-packages/Mako-0.8.1-py2.7.egg/mako/runtime.py", line 818, in _render_context _exec_template(inherit, lclcontext, args=args, kwargs=kwargs) File "/usr/lib/hue/build/env/lib/python2.7/site-packages/Mako-0.8.1-py2.7.egg/mako/runtime.py", line 844, in _exectemplate callable(context, _args, _kwargs) File "/tmp/tmp9S5muz/desktop/common_header.mako.py", line 248, in render_body __M_writer(unicode( conf.CUSTOM.BANNER_TOP_HTML.get() )) UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 0: ordinal not in range(128) Please fix this bug, Thank you!

— Reply to this email directly or view it on GitHub < https://github.com/cloudera/hue/issues/228>.

— Reply to this email directly or view it on GitHub https://github.com/cloudera/hue/issues/228#issuecomment-135671366.

enricoberti commented 9 years ago

This works!

banner_top_html='&#20013;&#25991;
screenshot 2015-08-28 11 39 38