def setUp(self): # call the base implementation super(ConfigurationEnabledTestCase, self).setUp() # configure the local service local.request = local.Process() local.worker = local.Process() # read the configuration conf_path = test_resource_path('conf', 'eureka.cfg.template') defaults = dict(here='string(default="%s")' % os.path.abspath(os.path.dirname(conf_path))) conf = read_application_options(conf_path, self.fail, defaults) # initialize the application context # no root component since we only want to perform the configuration app = BaseApplication(None) app.PLATFORM = "Eureka base" app.set_config(conf_path, conf, self.fail) app.set_base_url('http://localhost/') # dummy server host app.set_locale(i18n.Locale('en', 'US')) # Set the default Locale # install the configuration registry.configure(app.configuration) # configure the security manager security.set_manager(app.security)
def __init__(self): """Initialization """ super(Publisher, self).__init__() local.worker = local.Process() local.request = local.Process()
def configure(): """Configure the batch environment""" global apps # we suppose that the batch addresses only one application app_name, app = apps.items()[0] local.request = local.Process() local.worker = local.Process() log.set_logger('nagare.application.' + app.name) security.set_manager(app.security) # initialize the application context app.set_base_url('http://localhost/') # dummy server host app.set_locale(i18n.Locale('en', 'US')) # Set the default Locale # install the configuration registry.configure(app.configuration) # log the start of the script logger = log.get_logger('.' + __name__) logger.debug('----') logger.debug('Running %s\n' % sys.argv[0])
def create_fixture_app(app): local.worker = local.Process() local.request = local.Process() app = wsgi.create_WSGIApp(app) app.set_sessions_manager(SessionsWithPickledStates()) app.start() return fixture.TestApp(app)
def activate_applications(cfgfiles, debug, error): """Initialize applications In: - ``cfgfile`` -- paths to application configuration files or names of registered applications - ``debug`` -- enable the display of the generated SQL statements - ``error`` -- the function to call in case of configuration errors Return: - database session - {application name -> application object} """ # Configure the local service local.worker = local.Process() local.request = local.Process() configs = [] # Merge all the ``[logging]]`` section of all the applications for cfgfile in cfgfiles: # Read the configuration file of the application conffile, app, project_name, aconf = util.read_application( cfgfile, error) if conffile is None: error('Configuration file "%s" not found' % cfgfile) configs.append((conffile, app, project_name, aconf)) log.configure(aconf['logging'].dict(), aconf['application']['app']) # Configure the logging service log.activate() apps = {} # For each application given, activate its metadata and its logger for cfgfile, app, project_name, aconf in configs: name = aconf['application']['app'] log.set_logger('nagare.application.' + name) data_path = aconf['application']['data'] apps[name], databases = util.activate_WSGIApp(app, cfgfile, aconf, error, data_path=data_path, debug=debug) for database_settings, populate in databases: database.set_metadata(*database_settings) session = database.session session.begin() return session, apps
def setup_module(module): local.request = local.Process() locale = i18n.Locale('fr', 'FR', dirname=os.path.join(os.path.dirname(__file__), 'locale')) i18n.set_locale(locale)
def read_options(debug, args, error): """Activate all the database metadata objects of an application Several metadata objects can be activated if there are sub-sections into the [database] section. In: - ``debug`` -- flag to display the generated SQL statements - ``args`` -- arguments in the command lines: application to activate - ``error`` -- the function to call in case of configuration errors Return: - tuples (metadata object, populate function) """ # If no application name is given, display the list of the registered applications if not args: print 'Available applications:' app_names = [ entry.name for entry in pkg_resources.iter_entry_points('nagare.applications') ] for app_name in sorted(app_names): print ' -', app_name return () if len(args) != 1: error('Bad number of parameters') # Read the configuration of the application cfgfile, app, project_name, aconf = util.read_application(args[0], error) if cfgfile is None: error('Configuration file not found') # Configure the local service local.worker = local.Process() local.request = local.Process() # Configure the logging service log.configure(aconf['logging'].dict(), aconf['application']['name']) log.activate() log.set_logger('nagare.application.' + aconf['application']['name']) return util.activate_WSGIApp(app, cfgfile, aconf, error, debug=debug)[1]
def setup_module(module): local.request = local.Process()
def setup_module(module): local.request = local.Process() i18n.set_locale(i18n.Locale('fr', 'FR'))
def setUp(self): local.request = local.Process()
def setUp(self): local.request = local.Process() i18n.set_locale(i18n.Locale('fr', 'FR'))
# -- # Copyright (c) 2008-2017 Net-ng. # All rights reserved. # # This software is licensed under the BSD License, as described in # the file LICENSE.txt, which you should have received as part of # this distribution. # -- from nagare import local, wsgi from nagare.sessions import ExpirationError, common local.request = local.Process() def create_environ(): return { 'REQUEST_METHOD': 'GET', 'SCRIPT_NAME': '/app', 'PATH_INFO': '/', 'QUERY_STRING': '_s=10&_c=42', 'SERVER_PROTOCOL': 'HTTP/1.0', 'SERVER_NAME': 'localhost', 'SERVER_PORT': 8080, 'wsgi.url_scheme': 'http' } class Response(dict): def __init__(self): self.status_code = None