[ckan-dev] Home/landing page

Judith Moran Judith.Moran at nt.gov.au
Thu Mar 28 05:59:28 UTC 2019


HI,

The linux administrators advised that ckan is started by the following command:

systemctl start httpd

and stopped by

systemctl stop httpd.

And said I may run into trouble using:

. /usr/lib/ckan/default/bin/activate
cd /usr/lib/ckan/default/src/ckan
paster serve /etc/ckan/default/production.ini

I looked at activate and it does set environment variables that aren’t set now.


Also I updated the contents of (the theme we created) /usr/local/ckan/lib/default/src/ckanext-ntg_theme/requirements.txt to be the same as /usr/local/ckan/lib/default/src/ckan/requirements.txt.   I was thinking it may be using that custom requirements.txt, but it made no difference.

So maybe it is not possible to run debug using a dns via apache??  Is that correct….????

Should it harm the apache startup if I just do this:

. /usr/lib/ckan/default/bin/activate
cd /usr/lib/ckan/default/src/ckan
paster serve /etc/ckan/default/production.ini
after I do a systemctl stop httpd.



Some more details that may help with diagnosis.

Log has this error(see highlighted section)

[Thu Mar 28 13:38:32.247716 2019] [:error] [pid 4696] 2019-03-28 13:38:32,247 INFO  [ckan.config.environment] Loading static files from public
[Thu Mar 28 13:38:32.273549 2019] [:error] [pid 4696] 2019-03-28 13:38:32,273 INFO  [ckan.config.environment] Loading templates from /usr/local/ckan/lib/default/src/ckan/ckan/templates
[Thu Mar 28 13:38:32.560196 2019] [:error] [pid 4696] 2019-03-28 13:38:32,560 INFO  [ckan.config.environment] Loading templates from /usr/local/ckan/lib/default/src/ckan/ckan/templates
[Thu Mar 28 13:38:32.676271 2019] [:error] [pid 4696] [remote 155.205.101.73:0] mod_wsgi (pid=4696): Target WSGI script '/etc/ckan/default/apache.wsgi' cannot be loaded as Python module.
[Thu Mar 28 13:38:32.676297 2019] [:error] [pid 4696] [remote 155.205.101.73:0] mod_wsgi (pid=4696): Exception occurred processing WSGI script '/etc/ckan/default/apache.wsgi'.
[Thu Mar 28 13:38:32.676315 2019] [:error] [pid 4696] [remote 155.205.101.73:0] Traceback (most recent call last):
[Thu Mar 28 13:38:32.676330 2019] [:error] [pid 4696] [remote 155.205.101.73:0]   File "/etc/ckan/default/apache.wsgi", line 9, in <module>
[Thu Mar 28 13:38:32.676365 2019] [:error] [pid 4696] [remote 155.205.101.73:0]     application = loadapp('config:%s' % config_filepath)
[Thu Mar 28 13:38:32.676376 2019] [:error] [pid 4696] [remote 155.205.101.73:0]   File "/usr/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 247, in loadapp
[Thu Mar 28 13:38:32.676391 2019] [:error] [pid 4696] [remote 155.205.101.73:0]     return loadobj(APP, uri, name=name, **kw)
[Thu Mar 28 13:38:32.676399 2019] [:error] [pid 4696] [remote 155.205.101.73:0]   File "/usr/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 272, in loadobj
[Thu Mar 28 13:38:32.676409 2019] [:error] [pid 4696] [remote 155.205.101.73:0]     return context.create()
[Thu Mar 28 13:38:32.676417 2019] [:error] [pid 4696] [remote 155.205.101.73:0]   File "/usr/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 710, in create
[Thu Mar 28 13:38:32.676427 2019] [:error] [pid 4696] [remote 155.205.101.73:0]     return self.object_type.invoke(self)
[Thu Mar 28 13:38:32.676433 2019] [:error] [pid 4696] [remote 155.205.101.73:0]   File "/usr/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 146, in invoke
[Thu Mar 28 13:38:32.676444 2019] [:error] [pid 4696] [remote 155.205.101.73:0]     return fix_call(context.object, context.global_conf, **context.local_conf)
[Thu Mar 28 13:38:32.676451 2019] [:error] [pid 4696] [remote 155.205.101.73:0]   File "/usr/lib/python2.7/site-packages/paste/deploy/util.py", line 56, in fix_call
[Thu Mar 28 13:38:32.676462 2019] [:error] [pid 4696] [remote 155.205.101.73:0]     val = callable(*args, **kw)
[Thu Mar 28 13:38:32.676469 2019] [:error] [pid 4696] [remote 155.205.101.73:0]   File "/usr/local/ckan/lib/default/src/ckan/ckan/config/middleware/__init__.py", line 59, in make_app
[Thu Mar 28 13:38:32.676480 2019] [:error] [pid 4696] [remote 155.205.101.73:0]     flask_app = make_flask_stack(conf, **app_conf)
[Thu Mar 28 13:38:32.676488 2019] [:error] [pid 4696] [remote 155.205.101.73:0]   File "/usr/local/ckan/lib/default/src/ckan/ckan/config/middleware/flask_app.py", line 104, in make_flask_stack
[Thu Mar 28 13:38:32.676619 2019] [:error] [pid 4696] [remote 155.205.101.73:0]     from flask_debugtoolbar import DebugToolbarExtension
[Thu Mar 28 13:38:32.676641 2019] [:error] [pid 4696] [remote 155.205.101.73:0] ImportError: No module named flask_debugtoolbar
[Thu Mar 28 13:38:32.988897 2019] [:error] [pid 4696] [remote 155.205.101.73:232] mod_wsgi (pid=4696): Target WSGI script '/etc/ckan/default/apache.wsgi' cannot be loaded as Python module.
[Thu Mar 28 13:38:32.988921 2019] [:error] [pid 4696] [remote 155.205.101.73:232] mod_wsgi (pid=4696): Exception occurred processing WSGI script '/etc/ckan/default/apache.wsgi'.

IN /usr/local/ckan/lib/default/src/ckan/ckan/config/middleware/flask_app.py the following code applies to debug condition turned on.



                Line 75:     debug = asbool(conf.get('debug', conf.get('DEBUG', False)))
                Line 79:     app.debug = debug
                Line 79:     app.debug = debug
                Line 96:     # Secret key needed for flask-debug-toolbar and sessions
                                   if not app.config.get('SECRET_KEY'):
                                   app.config['SECRET_KEY'] = config.get('beaker.session.secret')
                                   if not app.config.get('SECRET_KEY'):
                                  raise RuntimeError(u'You must provide a value for the secret key'
                                   ' with the SECRET_KEY config option')
                Line 103:     if debug:
                Line 104:         from flask_debugtoolbar import DebugToolbarExtension
                Line 104:         from flask_debugtoolbar import DebugToolbarExtension
                Line 105:         app.config['DEBUG_TB_INTERCEPT_REDIRECTS'] = False
                Line 106:         DebugToolbarExtension(app)
                Line 208:     if debug:
                Line 372:             log.debug('Flask route match, endpoint: {0}, args: {1}, '
                Line 414:             log.debug(u'Registered core blueprint: {0!r}'.format(blueprint[0]))
                Line 433:     if not app.debug and not app.testing:


Then I found the directory /usr/local/ckan/lib/default/lib/python2.7/site-packages/flask

And in that is these 2 files.

-rw-r--r--.   1 apache apache  6024 Jan 25 16:20 debughelpers.py
-rw-r--r--.   1 apache apache  7215 Jan 25 16:20 debughelpers.pyc


Perhaps the full debugToolbarExtension components weren’t installed.

I imagine this comes with the install by default.

Any advice would be appreciated.

Jud.




From: ckan-dev [mailto:ckan-dev-bounces at lists.okfn.org] On Behalf Of Adrià Mercader
Sent: Wednesday, 27 March 2019 7:23 PM
To: CKAN Development Discussions <ckan-dev at lists.okfn.org>
Subject: Re: [ckan-dev] Home/landing page

Hi Judith,

To your original question, the home page is rendered using these templates:

https://github.com/ckan/ckan/blob/master/ckan/templates/home/index.html
https://github.com/ckan/ckan/blob/master/ckan/templates/home/layout1.html

Now, to run in development mode you first need to install the development requirements:

https://docs.ckan.org/en/latest/maintaining/installing/install-from-source.html#importerror-no-module-named-flask-debugtoolbar

You might need to change the path to the requirements file, and make sure to activate the virtualenv like Sam mentioned.

The Flask Debug Toolbar was introduced in recent versions so the documentation that you mention (2.3.x) is clearly outdated. You can check the version CKAN is running looking at the `ckan/__init__.py` file or visiting http://ckansite/api/action/status_show

Hope this helps,

Adrià


On Wed, 27 Mar 2019 at 09:07, Neuvonen Samuli <samuli.neuvonen at ymparisto.fi<mailto:samuli.neuvonen at ymparisto.fi>> wrote:
Hello,

I’m not sure what’s the official way to do it, but in our environment the way to run CKAN in debug mode is to do it locally, on the server. So, I do it as follows:


1.      Log on the server (remote desktop or Putty or whatever way you do it).

2.      Stop Apache:


apachectl stop


3.      Change parameters in the production.ini (or development.ini, if you use that) to something like:

debug = true
…
ckan.site_url = http://127.0.0.1:5000


4.      Start locally with paster:

. /usr/lib/ckan/default/bin/activate
cd /usr/lib/ckan/default/src/ckan
paster serve /etc/ckan/default/production.ini

After this, the site can viewed locally on the server, opening a browser at http://127.0.0.1:5000/.

When you want to return “online”, do the opposite (first killing the paster process).

Again, I’m not sure if this is the normal way to do it, especially as our CKAN version is a bit of a mix. In this case I hope someone else on the list can provide the correct way. I would be interested to hear it as well…

Hope this helps,
Sam


From: ckan-dev [mailto:ckan-dev-bounces at lists.okfn.org<mailto:ckan-dev-bounces at lists.okfn.org>] On Behalf Of Judith Moran
Sent: 27. maaliskuuta 2019 9:44
To: CKAN Development Discussions
Subject: Re: [ckan-dev] Home/landing page

Hi,

I changed to false and the home page fails to load.

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at root at localhost to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.


Previous CKAN person has made a new theme for site and it appears that debug does not work with the theme??

Hmm any suggestions.

Jud



From: ckan-dev [mailto:ckan-dev-bounces at lists.okfn.org<mailto:ckan-dev-bounces at lists.okfn.org>] On Behalf Of Neuvonen Samuli
Sent: Wednesday, 27 March 2019 3:48 PM
To: CKAN Development Discussions <ckan-dev at lists.okfn.org<mailto:ckan-dev at lists.okfn.org>>
Subject: Re: [ckan-dev] Home/landing page

Hello,

Not much more than a novice myself, I found it useful to run CKAN indebug-mode (https://docs.ckan.org/en/2.8/maintaining/configuration.html?highlight=debug#debug) to see what templates are used in each view. See more in Customizing CKAN’s templates (https://docs.ckan.org/en/2.8/theming/templates.html).

Also, the description of CKAN code architecture can help: https://docs.ckan.org/en/2.8/contributing/architecture.html

Regards,
Sam


From: ckan-dev [mailto:ckan-dev-bounces at lists.okfn.org] On Behalf Of Judith Moran
Sent: 27. maaliskuuta 2019 7:12
To: CKAN Development Discussions
Subject: [ckan-dev] Home/landing page

Hi,

Totally novice to CKAN.

Can someone explain how the home page is instigated in CKAN.


Thx



_______________________________________________
ckan-dev mailing list
ckan-dev at lists.okfn.org<mailto:ckan-dev at lists.okfn.org>
https://lists.okfn.org/mailman/listinfo/ckan-dev
Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20190328/f2c391fd/attachment-0002.html>


More information about the ckan-dev mailing list