def build_environment(request, response, session, store_current=True): """ Build the environment dictionary into which web2py files are executed. """ 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() # Enable standard conditional models (i.e., /*.py, /[controller]/*.py, and # /[controller]/[function]/*.py) response.models_to_run = [ r'^\w+\.py$', r'^%s/\w+\.py$' % request.controller, r'^%s/%s/\w+\.py$' % (request.controller, request.function) ] t = environment['T'] = translator(request) c = environment['cache'] = Cache(request) if store_current: current.globalenv = environment current.request = request current.response = response current.session = session current.T = t current.cache = c global __builtins__ if is_jython: # jython hack __builtins__ = mybuiltin() elif is_pypy: # apply the same hack to pypy too __builtins__ = mybuiltin() else: __builtins__['__import__'] = __builtin__.__import__ ### WHY? environment['__builtins__'] = __builtins__ environment['HTTP'] = HTTP environment['redirect'] = redirect environment['request'] = request environment['response'] = response environment['session'] = session environment['DAL'] = DAL environment['Field'] = Field environment['SQLDB'] = SQLDB # for backward compatibility environment['SQLField'] = SQLField # for backward compatibility environment['SQLFORM'] = SQLFORM environment['SQLTABLE'] = SQLTABLE environment['LOAD'] = LOAD environment['local_import'] = \ lambda name, reload=False, app=request.application:\ local_import_aux(name,reload,app) BaseAdapter.set_folder(pjoin(request.folder, 'databases')) response._view_environment = copy.copy(environment) return environment
def build_environment(request, response, session, store_current=True): """ Build the environment dictionary into which web2py files are executed. """ 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() # Enable standard conditional models (i.e., /*.py, /[controller]/*.py, and # /[controller]/[function]/*.py) response.models_to_run = [r'^\w+\.py$', r'^%s/\w+\.py$' % request.controller, r'^%s/%s/\w+\.py$' % (request.controller, request.function)] t = environment['T'] = translator(request) c = environment['cache'] = Cache(request) if store_current: current.globalenv = environment current.request = request current.response = response current.session = session current.T = t current.cache = c global __builtins__ if is_jython: # jython hack __builtins__ = mybuiltin() elif is_pypy: # apply the same hack to pypy too __builtins__ = mybuiltin() else: __builtins__['__import__'] = __builtin__.__import__ ### WHY? environment['__builtins__'] = __builtins__ environment['HTTP'] = HTTP environment['redirect'] = redirect environment['request'] = request environment['response'] = response environment['session'] = session environment['DAL'] = DAL environment['Field'] = Field environment['SQLDB'] = SQLDB # for backward compatibility environment['SQLField'] = SQLField # for backward compatibility environment['SQLFORM'] = SQLFORM environment['SQLTABLE'] = SQLTABLE environment['LOAD'] = LOAD environment['local_import'] = \ lambda name, reload=False, app=request.application:\ local_import_aux(name,reload,app) BaseAdapter.set_folder(pjoin(request.folder, 'databases')) response._view_environment = copy.copy(environment) return environment
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) if not request.env: request.env = Storage() t = environment['T'] = translator(request) c = environment['cache'] = Cache(request) if store_current: current.globalenv = environment current.request = request current.response = response current.session = session current.T = t current.cache = c global __builtins__ if is_jython: # jython hack __builtins__ = mybuiltin() elif is_pypy: # apply the same hack to pypy too __builtins__ = mybuiltin() else: __builtins__['__import__'] = __builtin__.__import__ ### WHY? environment['__builtins__'] = __builtins__ environment['HTTP'] = HTTP environment['redirect'] = redirect environment['request'] = request environment['response'] = response environment['session'] = session environment['DAL'] = DAL environment['Field'] = Field environment['SQLDB'] = SQLDB # for backward compatibility environment['SQLField'] = SQLField # for backward compatibility environment['SQLFORM'] = SQLFORM environment['SQLTABLE'] = SQLTABLE environment['LOAD'] = LOAD environment['local_import'] = \ lambda name, reload=False, app=request.application:\ local_import_aux(name,reload,app) BaseAdapter.set_folder(os.path.join(request.folder, 'databases')) response._view_environment = copy.copy(environment) return environment
def build_environment(request, response, session, store_current=True): """ Build the environment dictionary into which web2py files are executed. """ #h,v = html,validators environment = dict(_base_environment_) if not request.env: request.env = Storage() # Enable standard conditional models (i.e., /*.py, /[controller]/*.py, and # /[controller]/[function]/*.py) response.models_to_run = [ r'^\w+\.py$', r'^%s/\w+\.py$' % request.controller, r'^%s/%s/\w+\.py$' % (request.controller, request.function) ] t = environment['T'] = translator( os.path.join(request.folder, 'languages'), request.env.http_accept_language) c = environment['cache'] = Cache(request) if store_current: current.globalenv = environment current.request = request current.response = response current.session = session current.T = t current.cache = c global __builtins__ if is_jython: # jython hack __builtins__ = mybuiltin() elif is_pypy: # apply the same hack to pypy too __builtins__ = mybuiltin() else: __builtins__['__import__'] = __builtin__.__import__ # WHY? environment['request'] = request environment['response'] = response environment['session'] = session environment['local_import'] = \ lambda name, reload=False, app=request.application:\ local_import_aux(name, reload, app) BaseAdapter.set_folder(pjoin(request.folder, 'databases')) response._view_environment = copy.copy(environment) custom_import_install() return environment
def build_environment(request, response, session, store_current=True): """ Build the environment dictionary into which web2py files are executed. """ 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() t = environment["T"] = translator(request) c = environment["cache"] = Cache(request) if store_current: current.globalenv = environment current.request = request current.response = response current.session = session current.T = t current.cache = c global __builtins__ if is_jython: # jython hack __builtins__ = mybuiltin() elif is_pypy: # apply the same hack to pypy too __builtins__ = mybuiltin() else: __builtins__["__import__"] = __builtin__.__import__ ### WHY? environment["__builtins__"] = __builtins__ environment["HTTP"] = HTTP environment["redirect"] = redirect environment["request"] = request environment["response"] = response environment["session"] = session environment["DAL"] = DAL environment["Field"] = Field environment["SQLDB"] = SQLDB # for backward compatibility environment["SQLField"] = SQLField # for backward compatibility environment["SQLFORM"] = SQLFORM environment["SQLTABLE"] = SQLTABLE environment["LOAD"] = LOAD environment["local_import"] = lambda name, reload=False, app=request.application: local_import_aux( name, reload, app ) BaseAdapter.set_folder(pjoin(request.folder, "databases")) response._view_environment = copy.copy(environment) return environment
def build_environment(request, response, session, store_current=True): """ Build the environment dictionary into which web2py files are executed. """ # h,v = html,validators environment = dict(_base_environment_) if not request.env: request.env = Storage() # Enable standard conditional models (i.e., /*.py, /[controller]/*.py, and # /[controller]/[function]/*.py) response.models_to_run = [ r"^\w+\.py$", r"^%s/\w+\.py$" % request.controller, r"^%s/%s/\w+\.py$" % (request.controller, request.function), ] t = environment["T"] = translator(os.path.join(request.folder, "languages"), request.env.http_accept_language) c = environment["cache"] = Cache(request) if store_current: current.globalenv = environment current.request = request current.response = response current.session = session current.T = t current.cache = c global __builtins__ if is_jython: # jython hack __builtins__ = mybuiltin() elif is_pypy: # apply the same hack to pypy too __builtins__ = mybuiltin() else: __builtins__["__import__"] = __builtin__.__import__ # WHY? environment["request"] = request environment["response"] = response environment["session"] = session environment["local_import"] = lambda name, reload=False, app=request.application: local_import_aux( name, reload, app ) BaseAdapter.set_folder(pjoin(request.folder, "databases")) response._view_environment = copy.copy(environment) custom_import_install() return environment
def build_environment(request, response, session, store_current=True): """ Build the environment dictionary into which web2py files are executed. """ #h,v = html,validators environment = dict(_base_environment_) if not request.env: request.env = Storage() # Enable standard conditional models (i.e., /*.py, /[controller]/*.py, and # /[controller]/[function]/*.py) response.models_to_run = [r'^\w+\.py$', r'^%s/\w+\.py$' % request.controller, r'^%s/%s/\w+\.py$' % (request.controller, request.function)] t = environment['T'] = translator(request) c = environment['cache'] = Cache(request) if store_current: current.globalenv = environment current.request = request current.response = response current.session = session current.T = t current.cache = c global __builtins__ if is_jython: # jython hack __builtins__ = mybuiltin() elif is_pypy: # apply the same hack to pypy too __builtins__ = mybuiltin() else: __builtins__['__import__'] = __builtin__.__import__ # WHY? environment['request'] = request environment['response'] = response environment['session'] = session environment['local_import'] = \ lambda name, reload=False, app=request.application:\ local_import_aux(name, reload, app) BaseAdapter.set_folder(pjoin(request.folder, 'databases')) response._view_environment = copy.copy(environment) custom_import_install() return environment
def build_environment(request, response, session): """ 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) if not request.env: request.env = Storage() current.request = request current.response = response current.session = session current.T = environment['T'] = translator(request) current.cache = environment['cache'] = Cache(request) environment['HTTP'] = HTTP environment['redirect'] = redirect environment['request'] = request environment['response'] = response environment['session'] = session environment['DAL'] = DAL environment['Field'] = Field environment['SQLDB'] = SQLDB # for backward compatibility environment['SQLField'] = SQLField # for backward compatibility environment['SQLFORM'] = SQLFORM environment['SQLTABLE'] = SQLTABLE environment['LOAD'] = LoadFactory(environment) environment['local_import'] = \ lambda name, reload=False, app=request.application:\ local_import_aux(name,reload,app) BaseAdapter.set_folder(os.path.join(request.folder, 'databases')) response._view_environment = copy.copy(environment) return environment