aboutsummaryrefslogtreecommitdiffstats
path: root/debug_toolbar/utils/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'debug_toolbar/utils/__init__.py')
-rw-r--r--debug_toolbar/utils/__init__.py24
1 files changed, 19 insertions, 5 deletions
diff --git a/debug_toolbar/utils/__init__.py b/debug_toolbar/utils/__init__.py
index 2ce38db..c4dc160 100644
--- a/debug_toolbar/utils/__init__.py
+++ b/debug_toolbar/utils/__init__.py
@@ -47,7 +47,7 @@ def get_template_info(source, context_lines=3):
line = 0
upto = 0
source_lines = []
- before = during = after = ""
+ # before = during = after = ""
origin, (start, end) = source
template_source = origin.reload()
@@ -55,9 +55,9 @@ def get_template_info(source, context_lines=3):
for num, next in enumerate(linebreak_iter(template_source)):
if start >= upto and end <= next:
line = num
- before = template_source[upto:start]
- during = template_source[start:end]
- after = template_source[end:next]
+ # before = template_source[upto:start]
+ # during = template_source[start:end]
+ # after = template_source[end:next]
source_lines.append((num, template_source[upto:next]))
upto = next
@@ -75,4 +75,18 @@ def get_template_info(source, context_lines=3):
return {
'name': origin.name,
'context': context,
- } \ No newline at end of file
+ }
+
+def get_name_from_obj(obj):
+ if hasattr(obj, '__name__'):
+ name = obj.__name__
+ elif hasattr(obj, '__class__') and hasattr(obj.__class__, '__name__'):
+ name = obj.__class__.__name__
+ else:
+ name = '<unknown>'
+
+ if hasattr(obj, '__module__'):
+ module = obj.__module__
+ name = '%s.%s' % (module, name)
+
+ return name \ No newline at end of file