<s> from __future__ import absolute_import <EOL> from django import template <EOL> from django . conf import settings <EOL> from sentry . cache import default_cache <EOL> from sentry . models import ProjectKey <EOL> register = template . Library ( ) <EOL> def _get_project_key ( project_id ) : <EOL> try : <EOL> return ProjectKey . objects . filter ( <EOL> project = project_id , <EOL> roles = ProjectKey . roles . store , <EOL> ) [ <NUM_LIT:0> ] <EOL> except IndexError : <EOL> return None <EOL> @ register . simple_tag <EOL> def public_dsn ( ) : <EOL> project_id = settings . SENTRY_FRONTEND_PROJECT or settings . SENTRY_PROJECT <EOL> cache_key = '<STR_LIT>' % ( project_id , ) <EOL> result = default_cache . get ( cache_key ) <EOL> if result is None : <EOL> key = _get_project_key ( project_id ) <EOL> if key : <EOL> result = key . dsn_public <EOL> else : <EOL> result = '<STR_LIT>' <EOL> default_cache . set ( cache_key , result , <NUM_LIT> ) <EOL> return result </s>
