failed to access horizon web site if no install mox module

Bug #1297050 reported by huangyaowen on 2014-03-25
This bug report is a duplicate of:  Bug #1288245: mox is needed in requirements. Edit Remove
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Dashboard (Horizon)
Undecided
Unassigned

Bug Description

After installing the latest horizon codes and start the httpd, the horizon web site can't be accessed due to the following exception about "ImportError: No module named mox".

I did the initial investigation and found it's caused by the change(https://review.openstack.org/#/c/59580/) committed by Maxime Vidori on file horizon/site_urls.py. In this change, he add one new import line"from horizon.test.jasmine import jasmine", then it track back to file horizon/test/helpers.py and try to import mox module.

After install the mox module and restart httpd, then I can access to the horizon site.

However, from my view, it does NOT make sense: when I install openstack horizon on practical product env, I should not need to install the mox module(which is one python UT framework). it's better to change the file horizon/site_urls.py to dynamically import jasmine within the section when setting.DEBUG is true using import_module() method possibly like that:
if settings.DEBUG:
    try:
        mod = import_module('jasmine', 'horizon.test.jasmine')
        urlpatterns += patterns('',
        url(r'^qunit/$',
            TemplateView.as_view(template_name="horizon/qunit.html"),
            name='qunit_tests'),
        url(r'^jasmine/(.*?)$', mod.dispatcher))
    except ImportError:
        urlpatterns += patterns('',
        url(r'^qunit/$',
            TemplateView.as_view(template_name="horizon/qunit.html"),
            name='qunit_tests'))

Detail exception can be seen below:
[Mon Mar 24 08:09:17 2014] [error] [client 9.111.44.234] mod_wsgi (pid=23842): Exception occurred processing WSGI script '/usr/share/openstack-dashboard/opensta
ck_dashboard/wsgi/django.wsgi'.
[Mon Mar 24 08:09:17 2014] [error] [client 9.111.44.234] Traceback (most recent call last):
[Mon Mar 24 08:09:17 2014] [error] [client 9.111.44.234] File "/usr/lib/python2.6/site-packages/django/core/handlers/wsgi.py", line 241, in __call__
[Mon Mar 24 08:09:17 2014] [error] [client 9.111.44.234] response = self.get_response(request)
[Mon Mar 24 08:09:17 2014] [error] [client 9.111.44.234] File "/usr/lib/python2.6/site-packages/django/core/handlers/base.py", line 179, in get_response
[Mon Mar 24 08:09:17 2014] [error] [client 9.111.44.234] response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
[Mon Mar 24 08:09:17 2014] [error] [client 9.111.44.234] File "/usr/lib/python2.6/site-packages/django/core/handlers/base.py", line 224, in handle_uncaught_ex
ception
[Mon Mar 24 08:09:17 2014] [error] [client 9.111.44.234] if resolver.urlconf_module is None:
[Mon Mar 24 08:09:17 2014] [error] [client 9.111.44.234] File "/usr/lib/python2.6/site-packages/django/core/urlresolvers.py", line 323, in urlconf_module
[Mon Mar 24 08:09:17 2014] [error] [client 9.111.44.234] self._urlconf_module = import_module(self.urlconf_name)
[Mon Mar 24 08:09:17 2014] [error] [client 9.111.44.234] File "/usr/lib/python2.6/site-packages/django/utils/importlib.py", line 35, in import_module
[Mon Mar 24 08:09:17 2014] [error] [client 9.111.44.234] __import__(name)
[Mon Mar 24 08:09:17 2014] [error] [client 9.111.44.234] File "/usr/share/openstack-dashboard/openstack_dashboard/wsgi/../../openstack_dashboard/urls.py", lin
e 38, in <module>
[Mon Mar 24 08:09:17 2014] [error] [client 9.111.44.234] url(r'', include(horizon.urls))
[Mon Mar 24 08:09:17 2014] [error] [client 9.111.44.234] File "/usr/lib/python2.6/site-packages/django/conf/urls/__init__.py", line 25, in include
[Mon Mar 24 08:09:17 2014] [error] [client 9.111.44.234] patterns = getattr(urlconf_module, 'urlpatterns', urlconf_module)
[Mon Mar 24 08:09:17 2014] [error] [client 9.111.44.234] File "/usr/lib/python2.6/site-packages/django/utils/functional.py", line 184, in inner
[Mon Mar 24 08:09:17 2014] [error] [client 9.111.44.234] self._setup()
[Mon Mar 24 08:09:17 2014] [error] [client 9.111.44.234] File "/usr/lib/python2.6/site-packages/django/utils/functional.py", line 248, in _setup
[Mon Mar 24 08:09:17 2014] [error] [client 9.111.44.234] self._wrapped = self._setupfunc()
[Mon Mar 24 08:09:17 2014] [error] [client 9.111.44.234] File "/usr/lib/python2.6/site-packages/horizon/base.py", line 733, in url_patterns
[Mon Mar 24 08:09:17 2014] [error] [client 9.111.44.234] return self._urls()[0]
[Mon Mar 24 08:09:17 2014] [error] [client 9.111.44.234] File "/usr/lib/python2.6/site-packages/horizon/base.py", line 739, in _urls
[Mon Mar 24 08:09:17 2014] [error] [client 9.111.44.234] urlpatterns = self._get_default_urlpatterns()
[Mon Mar 24 08:09:17 2014] [error] [client 9.111.44.234] File "/usr/lib/python2.6/site-packages/horizon/base.py", line 82, in _get_default_urlpatterns
[Mon Mar 24 08:09:17 2014] [error] [client 9.111.44.234] mod = import_module(self.urls)
[Mon Mar 24 08:09:17 2014] [error] [client 9.111.44.234] File "/usr/lib/python2.6/site-packages/django/utils/importlib.py", line 35, in import_module
[Mon Mar 24 08:09:17 2014] [error] [client 9.111.44.234] __import__(name)
[Mon Mar 24 08:09:17 2014] [error] [client 9.111.44.234] File "/usr/lib/python2.6/site-packages/horizon/site_urls.py", line 26, in <module>
[Mon Mar 24 08:09:17 2014] [error] [client 9.111.44.234] from horizon.test.jasmine import jasmine
[Mon Mar 24 08:09:17 2014] [error] [client 9.111.44.234] File "/usr/lib/python2.6/site-packages/horizon/test/jasmine/jasmine.py", line 17, in <module>
[Mon Mar 24 08:09:17 2014] [error] [client 9.111.44.234] from horizon.test import helpers as test
[Mon Mar 24 08:09:17 2014] [error] [client 9.111.44.234] File "/usr/lib/python2.6/site-packages/horizon/test/helpers.py", line 50, in <module>
[Mon Mar 24 08:09:17 2014] [error] [client 9.111.44.234] import mox
[Mon Mar 24 08:09:17 2014] [error] [client 9.111.44.234] ImportError: No module named mox

This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers