Fix appadmin code inspection for db hooks

This commit is contained in:
ilvalle
2015-02-09 19:38:23 +01:00
parent 69c2bfba9a
commit e939d084fe
3 changed files with 42 additions and 30 deletions
@@ -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):