Skip to content

Commit

Permalink
Change interfaces property on Event to use import_string and to handl…
Browse files Browse the repository at this point in the history
…e missing interface imports
  • Loading branch information
dcramer committed Sep 4, 2012
1 parent fdc3fe8 commit ce52643
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/sentry/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
from sentry.utils import cached_property, \
MockDjangoRequest
from sentry.utils.models import Model, GzippedDictField, update
from sentry.utils.imports import import_string
from sentry.templatetags.sentry_helpers import truncatechars

__all__ = ('Event', 'Group', 'Project', 'SearchDocument')
Expand Down Expand Up @@ -514,13 +515,16 @@ def request(self):
@cached_property
def interfaces(self):
result = []
for k, v in self.data.iteritems():
if '.' not in k:
for key, data in self.data.iteritems():
if '.' not in key:
continue
m, c = k.rsplit('.', 1)
cls = getattr(__import__(m, {}, {}, [c]), c)
v = cls(**v)
result.append((v.score, k, v))

try:
cls = import_string(key)
except ImportError:
pass # suppress invalid interfaces
value = cls(**data)
result.append((value.score, key, value))
return SortedDict((k, v) for _, k, v in sorted(result, key=lambda x: x[0], reverse=True))

def get_version(self):
Expand Down

0 comments on commit ce52643

Please sign in to comment.