在Hue上设置默认页面

时间:2015-04-13 19:35:14

标签: django hadoop hue

我是Django的新手。我想对Hue(Hadoop UI)进行一些编辑,并且不知道要改变什么。我想将默认页面设置为filebrowser,这样当用户登录第一页时,他们将进入filebrowser。我知道Hue提供了一个重定向功能?next =,但这不适用于我的VIP(当我将我的VIP指向下一个URL时,它会重定向,但会解析为真正的IP地址而不是虚拟的,这不是我想要的是)。我想硬连线更改,以便默认网址始终是文件浏览器,我该怎么做?

我目前的策略是在/ desktop / core / src / desktop中编辑urls.py并添加以下行:

dynamic_patterns += patterns('filebrowser.views',
  url(r'^$', 'index', name='index'),
)

但是我一直收到错误:

Traceback:
File "/opt/mapr/hue/hue-3.6.0/build/env/lib/python2.6/site-packages/Django-1.4.5-py2.6.egg/django/core/handlers/base.py" in get_response
  111.                         response = callback(request, *callback_args, **callback_kwargs)
File "/opt/mapr/hue/hue-3.6.0/apps/filebrowser/src/filebrowser/views.py" in index
  99.   return view(request, path)
File "/opt/mapr/hue/hue-3.6.0/apps/filebrowser/src/filebrowser/views.py" in view
  161.             return listdir_paged(request, path)
File "/opt/mapr/hue/hue-3.6.0/apps/filebrowser/src/filebrowser/views.py" in listdir_paged
  435.     return render('listdir.mako', request, data)
File "/opt/mapr/hue/hue-3.6.0/desktop/core/src/desktop/lib/django_util.py" in render
  222.                                **kwargs)
File "/opt/mapr/hue/hue-3.6.0/desktop/core/src/desktop/lib/django_util.py" in _render_to_response
  144.     return django_mako.render_to_response(template, *args, **kwargs)
File "/opt/mapr/hue/hue-3.6.0/desktop/core/src/desktop/lib/django_mako.py" in render_to_response
  117.   return HttpResponse(render_to_string(template_name, data_dictionary), **kwargs)
File "/opt/mapr/hue/hue-3.6.0/desktop/core/src/desktop/lib/django_mako.py" in render_to_string_normal
  106.   result = template.render(**data_dict)
File "/opt/mapr/hue/hue-3.6.0/build/env/lib/python2.6/site-packages/Mako-0.8.1-py2.6.egg/mako/template.py" in render
  443.         return runtime._render(self, self.callable_, args, data)
File "/opt/mapr/hue/hue-3.6.0/build/env/lib/python2.6/site-packages/Mako-0.8.1-py2.6.egg/mako/runtime.py" in _render
  786.                             **_kwargs_for_callable(callable_, data))
File "/opt/mapr/hue/hue-3.6.0/build/env/lib/python2.6/site-packages/Mako-0.8.1-py2.6.egg/mako/runtime.py" in _render_context
  818.         _exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
File "/opt/mapr/hue/hue-3.6.0/build/env/lib/python2.6/site-packages/Mako-0.8.1-py2.6.egg/mako/runtime.py" in _exec_template
  844.         callable_(context, *args, **kwargs)
File "/tmp/tmp13I5gT/filebrowser/listdir.mako.py" in render_body
  73.         __M_writer(escape(unicode( fb_components.menubar() )))
File "/tmp/tmp13I5gT/filebrowser/fb_components.mako.py" in render_menubar
  260.         __M_writer(escape(unicode(app_name)))
File "/opt/mapr/hue/hue-3.6.0/build/env/lib/python2.6/site-packages/Mako-0.8.1-py2.6.egg/mako/runtime.py" in __str__
  205.         raise NameError("Undefined")

Exception Type: NameError at /
Exception Value: Undefined

1 个答案:

答案 0 :(得分:0)

我现在对Django有了更多的熟悉,并且能够满足我的要求。要更改登录后显示用户的页面,请编辑以下文件:

/desktop/core/src/desktop/views.py

在这里我们需要编辑索引函数 - 这里是之前和之后:

旧: def索引(请求):   if request.user.is_superuser和request.COOKIES.get(' hueLandingPage')!=' home':     返回重定向(反向(' about:index'))   其他:     回家(请求)

新: def索引(请求):   if request.user.is_superuser和request.COOKIES.get(' hueLandingPage')!=' home':     返回重定向(' filebrowser.views.index')     #return redirect(反向(' about:index'))   其他:     返回重定向(' filebrowser.views.index')     #return home(request)

你可以按照你喜欢的方式写出来(显然if条件在这里并不重要),但重点是让这个函数返回重定向(' filebrowser.views.index')

注意:我已将此解决方法与Hue 3.6和Hue 3.7

一起使用