Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Internal Server Error" when enabling 'pages' plugin #78

Open
astone123 opened this issue Jun 25, 2018 · 4 comments
Open

"Internal Server Error" when enabling 'pages' plugin #78

astone123 opened this issue Jun 25, 2018 · 4 comments

Comments

@astone123
Copy link

astone123 commented Jun 25, 2018

Whenever I add the pages plugin to my CKAN configuration file after following the install instructions in the Readme for this repository, I can't load my home page anymore. I get an internal server error.

I am running my CKAN instance with docker-compose. I installed ckanext-pages with pip inside of the Python venv running in the CKAN docker container. Then I added pages to my ckan.plugins section of my configuration. This part of my configuration is below:

ckan.plugins = stats text_view image_view recline_view datapusher datastore pages

CKAN runs fine if I remove the pages plugin from my configuration, but as soon as I add it back in, I can't load my home page anymore.

These are the logs in my CKAN container when I access my home page:

Traceback (most recent call last):
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/flask/app.py", line 1982, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/flask/app.py", line 1614, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/flask/app.py", line 1517, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/flask/app.py", line 1612, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/flask/app.py", line 1598, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/lib/ckan/venv/src/ckan/ckan/views/home.py", line 64, in index
    return base.render(u'home/index.html', extra_vars={})
  File "/usr/lib/ckan/venv/src/ckan/ckan/lib/base.py", line 127, in render
    return flask_render_template(template_name, **extra_vars)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/flask/templating.py", line 134, in render_template
    context, ctx.app)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/flask/templating.py", line 116, in _render
    rv = template.render(context)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/jinja2/environment.py", line 989, in render
    return self.environment.handle_exception(exc_info, True)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/jinja2/environment.py", line 754, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/lib/ckan/venv/src/ckan/ckan/templates/home/index.html", line 2, in top-level template code
    {% set homepage_style = ( g.homepage_style or '1' ) %}
  File "/usr/lib/ckan/venv/src/ckan/ckan/templates/page.html", line 1, in top-level template code
    {% extends "base.html" %}
  File "/usr/lib/ckan/venv/src/ckanext-pages/ckanext/pages/theme/templates_main/base.html", line 1, in top-level template code
    {% ckan_extends %}
  File "/usr/lib/ckan/venv/src/ckan/ckan/templates/base.html", line 101, in top-level template code
    {%- block page %}{% endblock -%}
  File "/usr/lib/ckan/venv/src/ckan/ckan/templates/page.html", line 14, in block "page"
    {%- block header %}
  File "/usr/lib/ckan/venv/src/ckan/ckan/templates/page.html", line 15, in block "header"
    {% include "header.html" %}
  File "/usr/lib/ckan/venv/src/ckanext-pages/ckanext/pages/theme/templates_main/header.html", line 1, in top-level template code
    {% ckan_extends %}
  File "/usr/lib/ckan/venv/src/ckan/ckan/templates/header.html", line 1, in top-level template code
    {% block header_wrapper %} {% block header_account %}
  File "/usr/lib/ckan/venv/src/ckan/ckan/templates/header.html", line 84, in block "header_wrapper"
    {% block header_site_navigation %}
  File "/usr/lib/ckan/venv/src/ckan/ckan/templates/header.html", line 87, in block "header_site_navigation"
    {% block header_site_navigation_tabs %} {{ h.build_nav_main( ('search', _('Datasets')), ('organizations_index', _('Organizations')),
  File "/usr/lib/ckan/venv/src/ckan/ckan/templates/header.html", line 87, in block "header_site_navigation_tabs"
    {% block header_site_navigation_tabs %} {{ h.build_nav_main( ('search', _('Datasets')), ('organizations_index', _('Organizations')),
  File "/usr/lib/ckan/venv/src/ckanext-pages/ckanext/pages/plugin.py", line 47, in build_pages_nav_main
    if (toolkit.c.action in ('pages_show', 'blog_show')
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/werkzeug/local.py", line 347, in __getattr__
    return getattr(self._get_current_object(), name)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/werkzeug/local.py", line 347, in __getattr__
    return getattr(self._get_current_object(), name)
  File "/usr/lib/ckan/venv/src/ckan/ckan/config/middleware/flask_app.py", line 334, in __getattr__
    return getattr(app_globals.app_globals, name)
AttributeError: '_Globals' object has no attribute 'action'
Traceback (most recent call last):
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/paste/httpserver.py", line 1068, in process_request_in_thread
    self.finish_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 334, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python2.7/SocketServer.py", line 655, in __init__
    self.handle()
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/paste/httpserver.py", line 442, in handle
    BaseHTTPRequestHandler.handle(self)
  File "/usr/lib/python2.7/BaseHTTPServer.py", line 340, in handle
    self.handle_one_request()
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/paste/httpserver.py", line 437, in handle_one_request
    self.wsgi_execute()
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/paste/httpserver.py", line 287, in wsgi_execute
    self.wsgi_start_response)
  File "/usr/lib/ckan/venv/src/ckan/ckan/config/middleware/__init__.py", line 202, in __call__
    return self.apps[app_name](environ, start_response)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/repoze/who/middleware.py", line 86, in __call__
    app_iter = app(environ, wrapper.wrap_start_response)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/webob/dec.py", line 147, in __call__
    resp = self.call_func(req, *args, **self.kwargs)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/webob/dec.py", line 208, in call_func
    return self.func(req, *args, **kwargs)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/fanstatic/publisher.py", line 234, in __call__
    return request.get_response(self.app)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/webob/request.py", line 1053, in get_response
    application, catch_exc_info=False)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/webob/request.py", line 1022, in call_application
    app_iter = application(self.environ, start_response)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/webob/dec.py", line 147, in __call__
    resp = self.call_func(req, *args, **self.kwargs)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/webob/dec.py", line 208, in call_func
    return self.func(req, *args, **kwargs)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/fanstatic/injector.py", line 54, in __call__
    response = request.get_response(self.app)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/webob/request.py", line 1053, in get_response
    application, catch_exc_info=False)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/webob/request.py", line 1022, in call_application
    app_iter = application(self.environ, start_response)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/flask/app.py", line 1997, in __call__
    return self.wsgi_app(environ, start_response)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/beaker/middleware.py", line 156, in __call__
    return self.wrap_app(environ, session_start_response)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/flask/app.py", line 1985, in wsgi_app
    response = self.handle_exception(e)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/flask/app.py", line 1547, in handle_exception
    return self.finalize_request(handler(e), from_error_handler=True)
  File "/usr/lib/ckan/venv/src/ckan/ckan/config/middleware/flask_app.py", line 411, in error_handler
    extra_vars = {u'code': e.code, u'content': e.description}
AttributeError: 'exceptions.AttributeError' object has no attribute 'code'

Does anyone know what could be going wrong here? I am running the latest version of CKAN (as of the date of this post). Any help would be appreciated.

@torfsen
Copy link
Contributor

torfsen commented Jun 26, 2018

Some of the errors in your traceback are related to templates -- the latest CKAN version is 2.8.0, which comes with a new version of the base templates. See the change log:

The default templates included in CKAN core have been updated to use Bootstrap 3. Extensions implementing custom themes are encouraged to update their templates, but they can still make CKAN load the old Bootstrap 2 templates during the transition using the following configuration options:

ckan.base_public_folder = public-bs2
ckan.base_templates_folder = templates-bs2

Which templates are you using? If you're using the new templates, could you please try with the legacy ones by including the lines above in your production.ini and restarting your web server?

@astone123
Copy link
Author

@torfsen, thanks for your response. I was unaware of the new base templates. I have added the configuration settings

ckan.base_public_folder = public-bs2
ckan.base_templates_folder = templates-bs2

to my production.ini file.

I still get an Internet Server Error when I try to load the home page of my site. Below are the logs from my container. I get similar error messages to the ones I was getting before. You can see at the top of the logs that the templates are now being loaded from the -bs2 folder.

2018-06-26 13:42:17,246 INFO  [ckan.config.environment] Loading static files from public-bs2
2018-06-26 13:42:18,628 INFO  [ckan.config.environment] Loading templates from /usr/lib/ckan/venv/src/ckan/ckan/templates-bs2
2018-06-26 13:42:19,026 INFO  [ckan.config.environment] Loading templates from /usr/lib/ckan/venv/src/ckan/ckan/templates-bs2
[2018-06-26 13:42:33,527] ERROR in app: Exception on / [GET]
Traceback (most recent call last):
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/flask/app.py", line 1982, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/flask/app.py", line 1614, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/flask/app.py", line 1517, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/flask/app.py", line 1612, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/flask/app.py", line 1598, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/lib/ckan/venv/src/ckan/ckan/views/home.py", line 64, in index
    return base.render(u'home/index.html', extra_vars={})
  File "/usr/lib/ckan/venv/src/ckan/ckan/lib/base.py", line 127, in render
    return flask_render_template(template_name, **extra_vars)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/flask/templating.py", line 134, in render_template
    context, ctx.app)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/flask/templating.py", line 116, in _render
    rv = template.render(context)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/jinja2/environment.py", line 989, in render
    return self.environment.handle_exception(exc_info, True)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/jinja2/environment.py", line 754, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/lib/ckan/venv/src/ckan/ckan/templates-bs2/home/index.html", line 2, in top-level template code
    {% set homepage_style = ( g.homepage_style or '1' ) %}
  File "/usr/lib/ckan/venv/src/ckan/ckan/templates-bs2/page.html", line 1, in top-level template code
    {% extends "base.html" %}
  File "/usr/lib/ckan/venv/src/ckanext-pages/ckanext/pages/theme/templates_main/base.html", line 1, in top-level template code
    {% ckan_extends %}
  File "/usr/lib/ckan/venv/src/ckan/ckan/templates-bs2/base.html", line 103, in top-level template code
    {%- block page %}{% endblock -%}
  File "/usr/lib/ckan/venv/src/ckan/ckan/templates-bs2/page.html", line 14, in block "page"
    {%- block header %}
  File "/usr/lib/ckan/venv/src/ckan/ckan/templates-bs2/page.html", line 15, in block "header"
    {% include "header.html" %}
  File "/usr/lib/ckan/venv/src/ckanext-pages/ckanext/pages/theme/templates_main/header.html", line 1, in top-level template code
    {% ckan_extends %}
  File "/usr/lib/ckan/venv/src/ckan/ckan/templates-bs2/header.html", line 1, in top-level template code
    {% block header_wrapper %}
  File "/usr/lib/ckan/venv/src/ckan/ckan/templates-bs2/header.html", line 96, in block "header_wrapper"
    {% block header_site_navigation %}
  File "/usr/lib/ckan/venv/src/ckan/ckan/templates-bs2/header.html", line 99, in block "header_site_navigation"
    {% block header_site_navigation_tabs %}
  File "/usr/lib/ckan/venv/src/ckan/ckan/templates-bs2/header.html", line 100, in block "header_site_navigation_tabs"
    {{ h.build_nav_main(
  File "/usr/lib/ckan/venv/src/ckanext-pages/ckanext/pages/plugin.py", line 47, in build_pages_nav_main
    if (toolkit.c.action in ('pages_show', 'blog_show')
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/werkzeug/local.py", line 347, in __getattr__
    return getattr(self._get_current_object(), name)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/werkzeug/local.py", line 347, in __getattr__
    return getattr(self._get_current_object(), name)
  File "/usr/lib/ckan/venv/src/ckan/ckan/config/middleware/flask_app.py", line 334, in __getattr__
    return getattr(app_globals.app_globals, name)
AttributeError: '_Globals' object has no attribute 'action'
Traceback (most recent call last):
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/paste/httpserver.py", line 1068, in process_request_in_thread
    self.finish_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 334, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python2.7/SocketServer.py", line 655, in __init__
    self.handle()
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/paste/httpserver.py", line 442, in handle
    BaseHTTPRequestHandler.handle(self)
  File "/usr/lib/python2.7/BaseHTTPServer.py", line 340, in handle
    self.handle_one_request()
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/paste/httpserver.py", line 437, in handle_one_request
    self.wsgi_execute()
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/paste/httpserver.py", line 287, in wsgi_execute
    self.wsgi_start_response)
  File "/usr/lib/ckan/venv/src/ckan/ckan/config/middleware/__init__.py", line 202, in __call__
    return self.apps[app_name](environ, start_response)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/repoze/who/middleware.py", line 86, in __call__
    app_iter = app(environ, wrapper.wrap_start_response)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/webob/dec.py", line 147, in __call__
    resp = self.call_func(req, *args, **self.kwargs)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/webob/dec.py", line 208, in call_func
    return self.func(req, *args, **kwargs)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/fanstatic/publisher.py", line 234, in __call__
    return request.get_response(self.app)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/webob/request.py", line 1053, in get_response
    application, catch_exc_info=False)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/webob/request.py", line 1022, in call_application
    app_iter = application(self.environ, start_response)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/webob/dec.py", line 147, in __call__
    resp = self.call_func(req, *args, **self.kwargs)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/webob/dec.py", line 208, in call_func
    return self.func(req, *args, **kwargs)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/fanstatic/injector.py", line 54, in __call__
    response = request.get_response(self.app)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/webob/request.py", line 1053, in get_response
    application, catch_exc_info=False)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/webob/request.py", line 1022, in call_application
    app_iter = application(self.environ, start_response)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/flask/app.py", line 1997, in __call__
    return self.wsgi_app(environ, start_response)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/beaker/middleware.py", line 156, in __call__
    return self.wrap_app(environ, session_start_response)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/flask/app.py", line 1985, in wsgi_app
    response = self.handle_exception(e)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/flask/app.py", line 1547, in handle_exception
    return self.finalize_request(handler(e), from_error_handler=True)
  File "/usr/lib/ckan/venv/src/ckan/ckan/config/middleware/flask_app.py", line 411, in error_handler
    extra_vars = {u'code': e.code, u'content': e.description}
AttributeError: 'exceptions.AttributeError' object has no attribute 'code'

Any other ideas? Thanks for your help!

@torfsen
Copy link
Contributor

torfsen commented Jun 27, 2018

Thanks for the update, @astone123! I can reproduce the issue.

You have triggered two different issues:

  1. A missing toolkit.c.action attribute (first traceback)
  2. A problem during the handling of the exception caused by the first issue (second traceback)

The second issue has already been noticed and fixed in CKAN core (see ckan/ckan#4257) but that fix hasn't been released, yet.

The first issue is also caused by changes in CKAN core -- I've opened ckan/ckan#4310 to investigate that further.

@astone123
Copy link
Author

Thanks for your help, @torfsen!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants