Closed oz123 closed 3 years ago
Are you absolutely sure that cb.__module__
and cb.__name__
are always defined, no matter what? How about getattr()
with a sensible default?
I think you are right. If views are created dynamically they might not have __module__
. The default is None
, so I don't think an exception will be thrown. __name__
is always defined.
Would you like me to change something?
I cannot think of a way to create a callable that does not define both attributes, so the change is fine I think.
The current improvement really helps when using multiple apps.
When I start such an application I like logging which routes are available, for example one can do:
Which previously gave this:
Memory addresses are of very little use (I can only tell which route is which because I mount them to different prefixes (e.g. editor, admin, etc.). This also mathes the directory structure on the file system. However, this is not always the case, some times I mount applications without prefix.
With the current patch I can immidietly tell where a route is coming from:
I think this little patch might be usefull for others too.