Ticket #11642: 11642-default-namespace-r11413.diff
File 11642-default-namespace-r11413.diff, 1.5 KB (added by , 15 years ago) |
---|
-
django/conf/urls/defaults.py
1 1 from django.core.urlresolvers import RegexURLPattern, RegexURLResolver 2 2 from django.core.exceptions import ImproperlyConfigured 3 from django.utils.importlib import import_module 3 4 4 5 __all__ = ['handler404', 'handler500', 'include', 'patterns', 'url'] 5 6 … … 8 9 9 10 def include(arg, namespace=None, app_name=None): 10 11 if isinstance(arg, tuple): 11 # callable returning a namespace hint 12 if namespace: 13 raise ImproperlyConfigured('Cannot override the namespace for a dynamic module that provides a namespace') 14 urlconf_module, app_name, namespace = arg 12 urlconf_module = arg[0] 13 app_name = app_name or arg[1] 14 namespace = namespace or arg[2] or app_name 15 15 else: 16 # No namespace hint - use manually provided namespace 17 urlconf_module = arg 16 if isinstance(arg, basestring): 17 urlconf_module = import_module(arg) 18 else: 19 urlconf_module = arg 20 # Get the default application namespace, specified in the app's urlconf. 21 app_name = app_name or getattr(urlconf_module, 'app_name', None) 22 # Use the app name as the default instance namespace. 23 namespace = namespace or app_name 18 24 return (urlconf_module, app_name, namespace) 19 25 20 26 def patterns(prefix, *args):