Skip to content

Commit

Permalink
Don't clobber cache with app-local networkbar links.
Browse files Browse the repository at this point in the history
  • Loading branch information
jace committed Dec 28, 2013
1 parent 726380d commit c386155
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions baseframe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,20 @@ def init_app(self, app, requires=[], bundle_js=None, bundle_css=None, assetenv=N


@networkbar_cache.cached(key_prefix='networkbar_links')
def networkbar_links():
links = current_app.config.get('NETWORKBAR_LINKS')
if links:
return links

def networkbar_links_fetcher():
try:
r = requests.get(current_app.config['NETWORKBAR_DATA'])
return (r.json() if callable(r.json) else r.json).get('links', [])
except: # Catch all exceptions
return []

def networkbar_links():
links = current_app.config.get('NETWORKBAR_LINKS')
if links:
return links

return networkbar_links_fetcher()


@baseframe.app_template_filter('render_field_options')
def render_field_options(field, **kwargs):
Expand Down

0 comments on commit c386155

Please sign in to comment.