55from inspect import isclass
66
77from django .conf .urls import url as django_url
8+ from django .views .generic import View
89
910def url (regex , view , kwargs = None , name = None ):
11+ if callable (view ) and hasattr (view , '__name__' ):
12+ view_name = "%s.%s" % (view .__module__ , view .__name__ )
13+ elif callable (view ) and hasattr (view , '__class__' ):
14+ view_name = "%s.%s" % (view .__module__ , view .__class__ .__name__ )
15+ else :
16+ view_name = regex
17+
1018 if name :
1119 branch = 'name'
1220 elif isinstance (view , (list , tuple )):
@@ -16,16 +24,22 @@ def url(regex, view, kwargs=None, name=None):
1624 name = view
1725 elif callable (view ) and hasattr (view , '__name__' ):
1826 branch = 'callable'
19- name = "%s.%s" % (view .__module__ , view .__name__ )
27+ name = view_name
28+ elif isinstance (view , View ):
29+ branch = 'view'
2030 elif isclass (view ) or hasattr (view , '__class__' ):
2131 branch = 'class'
2232 else :
2333 branch = 'notimpl'
2434 raise NotImplementedError ("Auto-named url from view of type %s: %s" % (type (view ), view ))
35+ if branch == 'name' :
36+ # List explicit url names with accompanying view dotted-path:
37+ #debug.say("%s %s" % (view_name, name))
38+ pass
2539 if name :
2640 branch = branch # silent pyflakes
2741 #debug.show('branch')
2842 #debug.show('name')
2943 pass
3044 return django_url (regex , view , kwargs = kwargs , name = name )
31-
45+
0 commit comments