Merge pull request #788 from ilvalle/admin-fix-inspect

Fix appadmin code inspection for db hooks
This commit is contained in:
mdipierro committed 2015-02-09 16:56:30 -06:00
commit 2aa8eaccb0
3 files changed
+12

No files matched your search

@@ -672,6 +672,7 @@ def hooks():
functions = [] functions = []
for f in getattr(db[t], op): for f in getattr(db[t], op):
if hasattr(f, '__call__'): if hasattr(f, '__call__'):
try:
if isinstance(f, (functools.partial)): if isinstance(f, (functools.partial)):
f = f.func f = f.func
filename = inspect.getsourcefile(f) filename = inspect.getsourcefile(f)
@@ -682,6 +683,9 @@ def hooks():
details['url'] = URL(a='admin',c='default',f='edit', args=[request['application'], details['filename']],vars={'lineno':details['lineno']}) details['url'] = URL(a='admin',c='default',f='edit', args=[request['application'], details['filename']],vars={'lineno':details['lineno']})
if details['filename'] or with_build_it: if details['filename'] or with_build_it:
functions.append(details) functions.append(details)
# compiled app and windows build don't support code inspection
except:
pass
if len(functions): if len(functions):
method_hooks.append({'name':op, 'functions':functions}) method_hooks.append({'name':op, 'functions':functions})
if len(method_hooks): if len(method_hooks):
@@ -672,6 +672,7 @@ def hooks():
functions = [] functions = []
for f in getattr(db[t], op): for f in getattr(db[t], op):
if hasattr(f, '__call__'): if hasattr(f, '__call__'):
try:
if isinstance(f, (functools.partial)): if isinstance(f, (functools.partial)):
f = f.func f = f.func
filename = inspect.getsourcefile(f) filename = inspect.getsourcefile(f)
@@ -682,6 +683,9 @@ def hooks():
details['url'] = URL(a='admin',c='default',f='edit', args=[request['application'], details['filename']],vars={'lineno':details['lineno']}) details['url'] = URL(a='admin',c='default',f='edit', args=[request['application'], details['filename']],vars={'lineno':details['lineno']})
if details['filename'] or with_build_it: if details['filename'] or with_build_it:
functions.append(details) functions.append(details)
# compiled app and windows build don't support code inspection
except:
pass
if len(functions): if len(functions):
method_hooks.append({'name':op, 'functions':functions}) method_hooks.append({'name':op, 'functions':functions})
if len(method_hooks): if len(method_hooks):
@@ -672,6 +672,7 @@ def hooks():
functions = [] functions = []
for f in getattr(db[t], op): for f in getattr(db[t], op):
if hasattr(f, '__call__'): if hasattr(f, '__call__'):
try:
if isinstance(f, (functools.partial)): if isinstance(f, (functools.partial)):
f = f.func f = f.func
filename = inspect.getsourcefile(f) filename = inspect.getsourcefile(f)
@@ -682,6 +683,9 @@ def hooks():
details['url'] = URL(a='admin',c='default',f='edit', args=[request['application'], details['filename']],vars={'lineno':details['lineno']}) details['url'] = URL(a='admin',c='default',f='edit', args=[request['application'], details['filename']],vars={'lineno':details['lineno']})
if details['filename'] or with_build_it: if details['filename'] or with_build_it:
functions.append(details) functions.append(details)
# compiled app and windows build don't support code inspection
except:
pass
if len(functions): if len(functions):
method_hooks.append({'name':op, 'functions':functions}) method_hooks.append({'name':op, 'functions':functions})
if len(method_hooks): if len(method_hooks):