fixed 1843, commented functions should not appear as if they are exposed
This commit is contained in:
@@ -1 +1 @@
|
|||||||
Version 2.8.2-stable+timestamp.2014.01.08.11.15.41
|
Version 2.8.2-stable+timestamp.2014.01.08.11.31.12
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ from gluon.admin import *
|
|||||||
from gluon.fileutils import abspath, read_file, write_file
|
from gluon.fileutils import abspath, read_file, write_file
|
||||||
from gluon.utils import web2py_uuid
|
from gluon.utils import web2py_uuid
|
||||||
from gluon.tools import Config
|
from gluon.tools import Config
|
||||||
|
from gluon.compileapp import find_exposed_functions
|
||||||
from glob import glob
|
from glob import glob
|
||||||
import shutil
|
import shutil
|
||||||
import platform
|
import platform
|
||||||
@@ -752,7 +753,7 @@ def edit():
|
|||||||
|
|
||||||
if len(request.args) > 2 and request.args[1] == 'controllers':
|
if len(request.args) > 2 and request.args[1] == 'controllers':
|
||||||
controller = (request.args[2])[:-3]
|
controller = (request.args[2])[:-3]
|
||||||
functions = regex_expose.findall(data)
|
functions = find_exposed_functions(data)
|
||||||
else:
|
else:
|
||||||
(controller, functions) = (None, None)
|
(controller, functions) = (None, None)
|
||||||
|
|
||||||
@@ -1065,7 +1066,7 @@ def design():
|
|||||||
functions = {}
|
functions = {}
|
||||||
for c in controllers:
|
for c in controllers:
|
||||||
data = safe_read(apath('%s/controllers/%s' % (app, c), r=request))
|
data = safe_read(apath('%s/controllers/%s' % (app, c), r=request))
|
||||||
items = regex_expose.findall(data)
|
items = find_exposed_functions(data)
|
||||||
functions[c] = items
|
functions[c] = items
|
||||||
|
|
||||||
# Get all views
|
# Get all views
|
||||||
@@ -1203,7 +1204,7 @@ def plugin():
|
|||||||
functions = {}
|
functions = {}
|
||||||
for c in controllers:
|
for c in controllers:
|
||||||
data = safe_read(apath('%s/controllers/%s' % (app, c), r=request))
|
data = safe_read(apath('%s/controllers/%s' % (app, c), r=request))
|
||||||
items = regex_expose.findall(data)
|
items = find_exposed_functions(data)
|
||||||
functions[c] = items
|
functions[c] = items
|
||||||
|
|
||||||
# Get all views
|
# Get all views
|
||||||
|
|||||||
+6
-3
@@ -22,7 +22,7 @@ from gluon.storage import Storage, List
|
|||||||
from gluon.template import parse_template
|
from gluon.template import parse_template
|
||||||
from gluon.restricted import restricted, compile2
|
from gluon.restricted import restricted, compile2
|
||||||
from gluon.fileutils import mktree, listdir, read_file, write_file
|
from gluon.fileutils import mktree, listdir, read_file, write_file
|
||||||
from gluon.myregex import regex_expose
|
from gluon.myregex import regex_expose, regex_longcomments
|
||||||
from gluon.languages import translator
|
from gluon.languages import translator
|
||||||
from gluon.dal import BaseAdapter, SQLDB, SQLField, DAL, Field
|
from gluon.dal import BaseAdapter, SQLDB, SQLField, DAL, Field
|
||||||
from gluon.sqlhtml import SQLFORM, SQLTABLE
|
from gluon.sqlhtml import SQLFORM, SQLTABLE
|
||||||
@@ -481,6 +481,9 @@ def compile_models(folder):
|
|||||||
save_pyc(filename)
|
save_pyc(filename)
|
||||||
os.unlink(filename)
|
os.unlink(filename)
|
||||||
|
|
||||||
|
def find_exposed_functions(data):
|
||||||
|
data = regex_longcomments.sub('',data)
|
||||||
|
return regex_expose.findall(data)
|
||||||
|
|
||||||
def compile_controllers(folder):
|
def compile_controllers(folder):
|
||||||
"""
|
"""
|
||||||
@@ -491,7 +494,7 @@ def compile_controllers(folder):
|
|||||||
for fname in listdir(path, '.+\.py$'):
|
for fname in listdir(path, '.+\.py$'):
|
||||||
### why is this here? save_pyc(pjoin(path, file))
|
### why is this here? save_pyc(pjoin(path, file))
|
||||||
data = read_file(pjoin(path, fname))
|
data = read_file(pjoin(path, fname))
|
||||||
exposed = regex_expose.findall(data)
|
exposed = find_exposed_functions(data)
|
||||||
for function in exposed:
|
for function in exposed:
|
||||||
command = data + "\nresponse._vars=response._caller(%s)\n" % \
|
command = data + "\nresponse._vars=response._caller(%s)\n" % \
|
||||||
function
|
function
|
||||||
@@ -602,7 +605,7 @@ def run_controller_in(controller, function, environment):
|
|||||||
rewrite.THREAD_LOCAL.routes.error_message % badc,
|
rewrite.THREAD_LOCAL.routes.error_message % badc,
|
||||||
web2py_error=badc)
|
web2py_error=badc)
|
||||||
code = read_file(filename)
|
code = read_file(filename)
|
||||||
exposed = regex_expose.findall(code)
|
exposed = find_exposed_functions(code)
|
||||||
if not function in exposed:
|
if not function in exposed:
|
||||||
raise HTTP(404,
|
raise HTTP(404,
|
||||||
rewrite.THREAD_LOCAL.routes.error_message % badf,
|
rewrite.THREAD_LOCAL.routes.error_message % badf,
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ regex_expose = re.compile(
|
|||||||
'^def\s+(?P<name>_?[a-zA-Z0-9]\w*)\( *\)\s*:',
|
'^def\s+(?P<name>_?[a-zA-Z0-9]\w*)\( *\)\s*:',
|
||||||
flags=re.M)
|
flags=re.M)
|
||||||
|
|
||||||
|
regex_longcomments = re.compile('(""".*?"""|'+"'''.*?''')",re.DOTALL)
|
||||||
|
|
||||||
regex_include = re.compile(
|
regex_include = re.compile(
|
||||||
'(?P<all>\{\{\s*include\s+[\'"](?P<name>[^\'"]*)[\'"]\s*\}\})')
|
'(?P<all>\{\{\s*include\s+[\'"](?P<name>[^\'"]*)[\'"]\s*\}\})')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user