many speed improvements, thanks Michele

This commit is contained in:
mdipierro
2012-08-28 08:28:36 -05:00
parent 37f81b48e8
commit 18a2c2c68e
4 changed files with 19 additions and 30 deletions
+10 -23
View File
@@ -160,12 +160,8 @@ def LOAD(c=None, f='index', args=None, vars=None,
if not isinstance(args,(list,tuple)):
args = [args]
c = c or request.controller
other_request = Storage()
for key, value in request.items():
other_request[key] = value
other_request['env'] = Storage()
for key, value in request.env.items():
other_request.env[key] = value
other_request = Storage(request)
other_request['env'] = Storage(request.env)
other_request.controller = c
other_request.function = f
other_request.extension = extension or request.extension
@@ -200,8 +196,7 @@ def LOAD(c=None, f='index', args=None, vars=None,
page = run_controller_in(c, f, other_environment)
if isinstance(page, dict):
other_response._vars = page
for key in page:
other_response._view_environment[key] = page[key]
other_response._view_environment.update(page)
run_view_in(other_response._view_environment)
page = other_response.body.getvalue()
current.request, current.response = original_request, original_response
@@ -245,12 +240,8 @@ class LoadFactory(object):
args = [args]
c = c or request.controller
other_request = Storage()
for key, value in request.items():
other_request[key] = value
other_request['env'] = Storage()
for key, value in request.env.items():
other_request.env['key'] = value
other_request = Storage(request)
other_request['env'] = Storage(request.env)
other_request.controller = c
other_request.function = f
other_request.extension = extension or request.extension
@@ -283,8 +274,7 @@ class LoadFactory(object):
page = run_controller_in(c, f, other_environment)
if isinstance(page, dict):
other_response._vars = page
for key in page:
other_response._view_environment[key] = page[key]
other_response._view_environment.update(page)
run_view_in(other_response._view_environment)
page = other_response.body.getvalue()
current.request, current.response = original_request, original_response
@@ -358,12 +348,9 @@ def build_environment(request, response, session, store_current=True):
"""
Build the environment dictionary into which web2py files are executed.
"""
environment = {}
for key in html.__all__:
environment[key] = getattr(html, key)
for key in validators.__all__:
environment[key] = getattr(validators, key)
h,v = html,validators
environment = dict((k,getattr(h,k)) for k in h.__all__)
environment.update((k,getattr(v, k)) for k in v.__all__)
if not request.env:
request.env = Storage()
@@ -592,7 +579,7 @@ def run_view_in(environment):
path = os.path.join(folder, 'compiled')
badv = 'invalid view (%s)' % response.view
patterns = response.generic_patterns or []
regex = re.compile('|'.join(fnmatch.translate(r) for r in patterns))
regex = re.compile('|'.join(map(fnmatch.translate, patterns)))
short_action = '%(controller)s/%(function)s.%(extension)s' % request
allow_generic = patterns and regex.search(short_action)
if not isinstance(response.view, str):