def get_sys_property(value=None, value_type=None): """ :param value: db.sys_properties.Property :param value_type: Python data type eg. int :return: db.sys_properties.PropertyValue """ cache_key = 'openstudio_system_property_' + value # Don't cache when running tests if web2pytest.is_running_under_test(request, request.application): sprop = _get_sys_property(value, value_type) else: sprop = cache.ram(cache_key, lambda: _get_sys_property(value, value_type), time_expire=CACHE_LONG) return sprop
from web2pytest import web2pytest import os import datetime # ------------------------------------------------------------------------- # if SSL/HTTPS is properly configured and you want all HTTP requests to # be redirected to HTTPS, uncomment the line below: # ------------------------------------------------------------------------- # request.requires_https() if not request.env.web2py_runtime_gae: # --------------------------------------------------------------------- # if NOT running on Google App Engine use SQLite or other DB # --------------------------------------------------------------------- ## if NOT running on Google App Engine use SQLite or other DB if web2pytest.is_running_under_test(request, request.application): # When running under test, db cannot be ':memory:' # because it is recreated in each request and a webclient test # can make many requests to validate a single scenario. db = DAL('sqlite://%s.sqlite' % request.application, folder=os.path.dirname(web2pytest.testfile_name()), pool_size=1, check_reserved=['all'], lazy_tables=False) else: db = DAL( myconf.get('db.uri'), pool_size=myconf.get('db.pool_size'), migrate_enabled=myconf.get('db.migrate'), check_reserved=['all'], db_codec=myconf.get('db.db_codec'),
(request, session, response, T, cache) = (current.request, current.session, current.response, current.t, current.cache) LOAD = compileapp.LoadFactory() from gluon.dal import DAL from gluon.sqlhtml import * from gluon.validators import * # NOTA IMPORTANTE: # Mientras se está en desarrollo, hay que poner migrate=True y lazy_tables=False # para que se puedan crear las tablas necesarias en la base de datos. # Una vez se pase a producción, migrate=False y lazy_tables=True # hará que sea mucho más rápida la ejecución de la aplicación: from gluon import current import datetime from web2pytest import web2pytest is_running_under_test = web2pytest.is_running_under_test(request, request.application) if is_running_under_test: from tempfile import mkdtemp folder = mkdtemp() db = DAL('sqlite://test.sqlite', pool_size=10, check_reserved=['all'], folder=folder) else: db = DAL('sqlite://storage.sqlite', pool_size=1, check_reserved=['all'], migrate=True, lazy_tables=False) current.db = db # by default give a view/generic.extension to all actions from localhost # none otherwise. a pattern can be 'controller/function.extension' response.generic_patterns = (['*'] if request.is_local else [])