[ckan-dev] Action functions raising exceptions

Sean Hammond sean.hammond at okfn.org
Tue Aug 13 15:31:31 UTC 2013


Dominik noticed this problem:

- All action functions are available to templates via
  ckan.lib.helpers.get_action()

- Action functions can raise exceptions, e.g. NotFound if you call
  user_show() for a user that doesn't exist (generally lots of action
  functions raise lots of exceptions for lots of reasons)

- Jinja templates cannot catch exceptions (as far as I know)

- Template crashes, CKAN crashes

It seems to me that either:

1. Action functions all have to be changed to not raise exceptions, or

2. Action functions should not be available to templates (but we can
   have template helper functions for individual action functions that
   catch any exceptions raised and handle them appropriately), or

3. lib.helpers.get_action() catches all exceptions and returns some sort
   of error dict or something that then allows us to put error-handling
   logic into the templates

Maybe there are other possible solutions but those are the 3 I can think
of.




More information about the ckan-dev mailing list