[ckan-changes] [okfn/ckan] e8c1cd: [#1635] Change email notifications paster command ...

GitHub noreply at github.com
Wed Dec 5 18:19:58 UTC 2012


  Branch: refs/heads/1635-feature-email-notifications-for-activity-streams
  Home:   https://github.com/okfn/ckan
  Commit: e8c1cdb85857b3b53eceddf4caa962407bbdfe7e
      https://github.com/okfn/ckan/commit/e8c1cdb85857b3b53eceddf4caa962407bbdfe7e
  Author: Sean Hammond <seanhammond at lavabit.com>
  Date:   2012-12-05 (Wed, 05 Dec 2012)

  Changed paths:
    M ckan/lib/cli.py
    M ckan/logic/action/update.py
    M ckan/logic/auth/publisher/update.py
    M ckan/logic/auth/update.py
    M setup.py

  Log Message:
  -----------
  [#1635] Change email notifications paster command to an API function

Move the send-email-notifications paster command added in commit
0d9e6274991393c28e3bbe9b930a0551dd627ae7 to a logic action function that only
sysadmins are authorised to use.

I was running into too many problems with the paster command because it runs
outside of a Pylons request thread so various Pylons objects used throughout
CKAN are not registered.

This way, the command can still be called from cron via:

    echo '{}' | paster post development.ini /api/action/send_email_notifications

this simulates an HTTP request, so all the Pylons objects are registered for
the thread. The `echo '{}' | ` part is unfortunately necessary because the CKAN
API still requires any empty data dict to be posted when the function being
called doesn't take any arguments.

The action function checks whether it is being run via paster and if so, skips
the authorisation check. This just makes it simpler to use as it means you
don't have to POST a sysadmin's API key when calling the command via paster.

This makes the changes to ckan/lib/mailer.py that I did in commit
ed221a2e52d3ee317a0f0e3b955c7bfbffa11286 unnecessary, but I'm leaving them in
because I don't think they do any harm and they may prove useful one day.

This means that the email notifications tests can become API tests now, and I
should add some tests for the auth of the new API function.


  Commit: 9c797ac4011159e7e8fdb3a0a7ae3338d0cc50f2
      https://github.com/okfn/ckan/commit/9c797ac4011159e7e8fdb3a0a7ae3338d0cc50f2
  Author: Sean Hammond <seanhammond at lavabit.com>
  Date:   2012-12-05 (Wed, 05 Dec 2012)

  Changed paths:
    M ckan/tests/lib/test_email_notifications.py

  Log Message:
  -----------
  [#1635] Factor out unneeded post() function

test_email_notifications.py no longer needs its own post() function as
it can use ckan.tests.call_action_api()


  Commit: bcf6d8943d078b9950d2919ec20fc631addddf64
      https://github.com/okfn/ckan/commit/bcf6d8943d078b9950d2919ec20fc631addddf64
  Author: Sean Hammond <seanhammond at lavabit.com>
  Date:   2012-12-05 (Wed, 05 Dec 2012)

  Changed paths:
    M ckan/tests/lib/test_email_notifications.py

  Log Message:
  -----------
  [#1635] Use send_email_notifications API in tests

Call the new send_email_notifications API endpoint in the tests, rather
than calling the lib function directly.


  Commit: c770f11474539a25c2f370b82458a6dbd481ef1e
      https://github.com/okfn/ckan/commit/c770f11474539a25c2f370b82458a6dbd481ef1e
  Author: Sean Hammond <seanhammond at lavabit.com>
  Date:   2012-12-05 (Wed, 05 Dec 2012)

  Changed paths:
    A ckan/tests/functional/api/test_email_notifications.py
    R ckan/tests/lib/test_email_notifications.py

  Log Message:
  -----------
  [#1635] Move email notification tests into api dir

The tests now test everything via the API, so move the file into
tests/functional/api/ with the other API tests


  Commit: aa48871d227c3514ada848907ff472edbec801e9
      https://github.com/okfn/ckan/commit/aa48871d227c3514ada848907ff472edbec801e9
  Author: Sean Hammond <seanhammond at lavabit.com>
  Date:   2012-12-05 (Wed, 05 Dec 2012)

  Changed paths:
    M ckan/tests/functional/api/test_email_notifications.py

  Log Message:
  -----------
  [#1635] Add auth tests for email notifications

Add a couple of tests to make sure that users who are not sysadmins
cannot call the send_email_notifications API.


Compare: https://github.com/okfn/ckan/compare/ce7041fb8489...aa48871d227c


More information about the ckan-changes mailing list