forked from 0x2620/pandora
api py3 fix
This commit is contained in:
parent
ee2c59047b
commit
263b5c9ce2
1 changed files with 8 additions and 3 deletions
|
@ -5,6 +5,7 @@ from __future__ import division, absolute_import
|
|||
import inspect
|
||||
import sys
|
||||
|
||||
from six import PY2
|
||||
from django.conf import settings
|
||||
|
||||
from ..shortcuts import render_to_json_response, json_response
|
||||
|
@ -109,8 +110,12 @@ class ApiActions(dict):
|
|||
if name != 'api' and hasattr(f, 'func_closure') and f.func_closure:
|
||||
fc = filter(lambda c: hasattr(c.cell_contents, '__call__'), f.func_closure)
|
||||
f = fc[len(fc)-1].cell_contents
|
||||
if PY2:
|
||||
info = f.func_code.co_filename[len(settings.PROJECT_ROOT)+1:]
|
||||
info = u'%s:%s' % (info, f.func_code.co_firstlineno)
|
||||
else:
|
||||
info = f.__code__.co_filename[len(settings.PROJECT_ROOT)+1:]
|
||||
info = u'%s:%s' % (info, f.__code__.co_firstlineno)
|
||||
return info, trim(inspect.getsource(f))
|
||||
|
||||
def register(self, method, action=None, cache=True, version=None):
|
||||
|
|
Loading…
Reference in a new issue