Skip to content

Commit

Permalink
display debug info
Browse files Browse the repository at this point in the history
  • Loading branch information
jedie committed Jul 8, 2010
1 parent 82a78ab commit 7bc53cf
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions django_tools/utils/installed_apps_utils.py
Expand Up @@ -16,6 +16,7 @@
from django.core import urlresolvers
from django.utils.importlib import import_module

DEBUG = 1

def get_filtered_apps(resolve_url="/", no_args=True):
"""
Expand All @@ -37,21 +38,29 @@ def get_filtered_apps(resolve_url="/", no_args=True):
try:
url_mod = import_module(urls_pkg)
except ImportError, err:
if DEBUG > 2:
print "Skip %r: has no urls.py" % app_label
if str(err) == "No module named urls":
continue
raise

if DEBUG > 1:
print "found %r with urls.py" % app_label

try:
urlpatterns = url_mod.urlpatterns
except AttributeError:
if DEBUG:
print "Skip %r: urls.py has no 'urlpatterns'" % app_label
continue

resolver = urlresolvers.RegexURLResolver(r'^/', urlpatterns)
try:
func, func_args, func_kwargs = resolver.resolve(resolve_url)
except urlresolvers.Resolver404:
except urlresolvers.Resolver404, err:
if DEBUG:
print "Skip %r: Can't handle root url - %s" % (app_label, err)
continue

if not no_args or func_args == () and func_kwargs == {}:
root_apps.append(app_label)
return root_apps
Expand Down

0 comments on commit 7bc53cf

Please sign in to comment.