[ckan-dev] How to debug problem with overridden package controller?

Denis Zgonjanin deniszgonjanin at gmail.com
Wed Feb 4 19:05:11 UTC 2015


Hi Bruce,

Have you tried setting some breakpoints and debugging? Pick a place where
you might suspect something is going wrong, and put in the following:

import pdb; pdb.set_trace()

Then run CKAN with paster, and trigger that code. That should let you poke
around on the command line. (https://docs.python.org/2/library/pdb.html)

If you want to inspect stuff on the template side, paster/pylons runs in
debug mode with an interactive web debugger of sorts. Run CKAN with paster
with debug set to True and purposely put breaking code in your jinja
templates where you want to debug, something like {{5/0}}. This way you'll
get a debug view which will let you debug right within your browser.

Hope this helps,
Denis

On Wed, Feb 4, 2015 at 1:53 PM, Bruce Crevensten <becrevensten at alaska.edu>
wrote:

> Hi,
>
> I've overridden the 'before_view' method of the IPackageController per the
> documentation (which is excellent) and am using that to make some
> additional fields available to customize the display of our data sets.  For
> the most part, this is working fine and seems like the right approach,
> using code along the lines of:
>
> pkg_dict['custom_vield'] = 'value'
>
> ...then returning the modified pkg_dict at the end of the before_view
> method.
>
> But I've run into a problem with one particular data set and I don't
> understand where to see the cause of the error.
>
> The symptom is that none of my additional fields show up in the debug info
> on the page, for example if I toggle the variable display showing variables
> available to a snippet, I see this:
>
> extent: u'{"type": "Point", "coordinates": [0.0, 90.0]}'
> temporal_start: Undefined
> spatial_resolution: Undefined
> temporal_end: Undefined
>
> ...where 'temporal_start', 'temporal_end' and 'spatial_resolution' are
> some fields that I set up in my before_view method.
>
> There's no Jinja2 error dump.  I've got my dev instance configured to be
> in debug mode.  The only log reference seems to indicate that an error is
> occurring somewhere, but it doesn't give me a good clue about where to look
> -- the output from my /var/log/httpd/ckan.error.log shows this when I
> render this data set:
>
> [Wed Feb 04 18:40:15 2015] [error] 2015-02-04 18:40:15,169 INFO
>  [ckan.lib.base]
>  /dataset/projected-daily-quantile-mapped-near-surface-wind-velocity-2-5-degrees-cmip5-ar5
> render time 0.996 seconds
> [Wed Feb 04 18:40:15 2015] [error] 2015-02-04 18:40:15,760 INFO
>  [ckan.lib.base]  /api/i18n/en render time 0.002 seconds
>
> ...and the ckan.custom.log file doesn't have any information either.
>
> What is the right strategy for debugging this type of error?
>
> --
> *Bruce Crevensten*
>
>
> *Senior Software Engineer*
> (SNAP) Scenarios Network for Alaska & Arctic Planning
> www.snap.uaf.edu
>
> _______________________________________________
> ckan-dev mailing list
> 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/20150204/bf2de202/attachment-0003.html>


More information about the ckan-dev mailing list