Skip to content

Commit

Permalink
Fixes KeyError when there isn't an event in the registry.
Browse files Browse the repository at this point in the history
  • Loading branch information
skeet70 committed Jun 1, 2012
1 parent fdeb3f4 commit a1f25cb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions brabeion/internals.py
Expand Up @@ -26,8 +26,9 @@ def register(self, badge):
self._event_registry.setdefault(event, []).append(badge)

def possibly_award_badge(self, event, **state):
for badge in self._event_registry[event]:
badge.possibly_award(**state)
if event in self._event_registry:
for badge in self._event_registry[event]:
badge.possibly_award(**state)


badges = BadgeCache()
2 changes: 1 addition & 1 deletion docs/models.txt
Expand Up @@ -3,7 +3,7 @@ Models in ``brabeion``

.. module:: brabeion.models

.. class:: BadgeAwarded(models.Model)
.. class:: BadgeAward(models.Model)

.. attribute:: user

Expand Down
2 changes: 1 addition & 1 deletion docs/usage.txt
Expand Up @@ -100,7 +100,7 @@ to the user:

By default badges will be awarded at the current time, if you need to overide
the award time of the badge you can pass a ``force_timestamp`` keyword argument
to ``possible_award_badge()``.
to ``possibly_award_badge()``.

Asynchronous Badges
-------------------
Expand Down

0 comments on commit a1f25cb

Please sign in to comment.