Skip to content

Commit

Permalink
[#1635] user_dictize() don't crash if no context['user']
Browse files Browse the repository at this point in the history
Normally 'user' would always be in context (and would be None if no user
was logged in) but if user_dictize() was called via an internal function
calling a logic action function via get_action(), and that internal
function neglected to put 'user': None in context, then user_dictize()
would raise KeyError. (An example of this is the
get_and_send_notifications_for_all_users() that I'm about to commit
after this.)

May as well just behave as if 'user': None was in context instead.
  • Loading branch information
Sean Hammond committed Nov 16, 2012
1 parent 819d192 commit a3d31e5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion ckan/lib/dictization/model_dictize.py
Expand Up @@ -399,7 +399,7 @@ def user_dictize(user, context):
result_dict['number_of_edits'] = user.number_of_edits()
result_dict['number_administered_packages'] = user.number_administered_packages()

requester = context['user']
requester = context.get('user')

if not (ckan.authz.Authorizer().is_sysadmin(unicode(requester)) or
requester == user.name or
Expand Down

0 comments on commit a3d31e5

Please sign in to comment.