Skip to content

Commit

Permalink
Merge pull request #15 from aldryn/feature/conservative_get_app_instance
Browse files Browse the repository at this point in the history
Add checks to get_app_instance to avoid Resolver404
  • Loading branch information
yakky committed Mar 13, 2015
2 parents d33f225 + be2cd54 commit 50f519a
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions aldryn_apphooks_config/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from app_data import AppDataContainer, app_registry
from cms.apphook_pool import apphook_pool
from django.core.urlresolvers import resolve
from django.core.urlresolvers import resolve, Resolver404


def get_app_instance(request):
Expand All @@ -15,11 +15,16 @@ def get_app_instance(request):
if getattr(request, 'current_page', None):
app = apphook_pool.get_apphook(request.current_page.application_urls)

config = None
namespace = resolve(request.path_info).namespace
if app and app.app_config:
config = app.get_config(namespace)
return namespace, config
try:
config = None
namespace = resolve(request.path).namespace
if app and app.app_config:
config = app.get_config(namespace)
return namespace, config
except Resolver404:
pass
return '', None


def setup_config(form_class, config_model):
Expand Down

0 comments on commit 50f519a

Please sign in to comment.