def _create_api_server(self, request_data, storage_path, options, configuration): self._dispatcher = sandbox._create_dispatcher(configuration, options) self._dispatcher._port = options.port self._dispatcher._host = options.host # Make sure the dispatcher uses the WSGIRequestInfo object already instantiated in local sandbox. # Without this, there will be references to two different request info objects, causing errors when trying # to access a request in one that was started in the other. def request_data_override(func, _request_data): def _wrapped(api_host, api_port, request_data): return func(api_host, api_port, _request_data) return _wrapped self._dispatcher.start = request_data_override(self._dispatcher.start, self._dispatcher._request_data) sandbox._API_SERVER._host = options.api_host sandbox._API_SERVER.bind_addr = (options.api_host, options.api_port) request_data._dispatcher = self._dispatcher from google.appengine.api import apiproxy_stub_map task_queue = apiproxy_stub_map.apiproxy.GetStub('taskqueue') # Make sure task running is enabled (it's disabled in the sandbox by default) if not task_queue._auto_task_running: task_queue._auto_task_running = True task_queue.StartBackgroundExecution() return sandbox._API_SERVER
def _create_api_server(self, request_data, storage_path, options, configuration): self._dispatcher = sandbox._create_dispatcher( configuration, options) self._dispatcher._port = options.port self._dispatcher._host = options.host # Make sure the dispatcher uses the WSGIRequestInfo object already instantiated in local sandbox. # Without this, there will be references to two different request info objects, causing errors when trying # to access a request in one that was started in the other. def request_data_override(func, _request_data): def _wrapped(api_host, api_port, request_data): return func(api_host, api_port, _request_data) return _wrapped self._dispatcher.start = request_data_override( self._dispatcher.start, self._dispatcher._request_data) sandbox._API_SERVER._host = options.api_host sandbox._API_SERVER.bind_addr = (options.api_host, options.api_port) request_data._dispatcher = self._dispatcher from google.appengine.api import apiproxy_stub_map task_queue = apiproxy_stub_map.apiproxy.GetStub('taskqueue') # Make sure task running is enabled (it's disabled in the sandbox by default) if not task_queue._auto_task_running: task_queue._auto_task_running = True task_queue.StartBackgroundExecution() return sandbox._API_SERVER
def _create_api_server(self, request_data, storage_path, options, configuration): # sandbox._create_dispatcher returns a singleton dispatcher instance made in sandbox self._dispatcher = sandbox._create_dispatcher( configuration, options) # the dispatcher may have passed environment variables, it should be propagated env_vars = self._dispatcher._configuration.modules[ 0]._app_info_external.env_variables or EnvironmentVariables( ) for module in configuration.modules: module_name = module._module_name if module_name == 'default' or module_name is None: module_settings = 'DJANGO_SETTINGS_MODULE' else: module_settings = '%s_DJANGO_SETTINGS_MODULE' % module_name if module_settings in env_vars: module_env_vars = module.env_variables or EnvironmentVariables( ) module_env_vars['DJANGO_SETTINGS_MODULE'] = env_vars[ module_settings] old_env_vars = module._app_info_external.env_variables new_env_vars = EnvironmentVariables.Merge( module_env_vars, old_env_vars) module._app_info_external.env_variables = new_env_vars self._dispatcher._configuration = configuration self._dispatcher._port = options.port self._dispatcher._host = options.host # Because the dispatcher is a singleton, we need to set the threadsafe override here # depending on what was passed to the runserver command. This entire file really needs rebuilding # we have way too many hacks in here! self._dispatcher._module_to_threadsafe_override[ configuration.modules[0]. module_name] = options.threadsafe_override self._dispatcher.request_data = request_data request_data._dispatcher = self._dispatcher sandbox._API_SERVER._host = options.api_host sandbox._API_SERVER.bind_addr = (options.api_host, options.api_port) from google.appengine.api import apiproxy_stub_map task_queue = apiproxy_stub_map.apiproxy.GetStub('taskqueue') # Make sure task running is enabled (it's disabled in the sandbox by default) if not task_queue._auto_task_running: task_queue._auto_task_running = True task_queue.StartBackgroundExecution() return sandbox._API_SERVER
def _create_api_server(self, request_data, storage_path, options, configuration): self._dispatcher = sandbox._create_dispatcher(configuration, options) self._dispatcher._port = options.port self._dispatcher._host = options.host sandbox._API_SERVER._host = options.api_host sandbox._API_SERVER.bind_addr = (options.api_host, options.api_port) request_data._dispatcher = self._dispatcher from google.appengine.api import apiproxy_stub_map task_queue = apiproxy_stub_map.apiproxy.GetStub('taskqueue') # Make sure task running is enabled (it's disabled in the sandbox by default) if not task_queue._auto_task_running: task_queue._auto_task_running = True task_queue.StartBackgroundExecution() return sandbox._API_SERVER
def _create_api_server(self, request_data, storage_path, options, configuration): # sandbox._create_dispatcher returns a singleton dispatcher instance made in sandbox self._dispatcher = sandbox._create_dispatcher(configuration, options) # the dispatcher may have passed environment variables, it should be propagated env_vars = self._dispatcher._configuration.modules[0]._app_info_external.env_variables or EnvironmentVariables() for module in configuration.modules: module_name = module._module_name if module_name == 'default' or module_name is None: module_settings = 'DJANGO_SETTINGS_MODULE' else: module_settings = '%s_DJANGO_SETTINGS_MODULE' % module_name if module_settings in env_vars: module_env_vars = module.env_variables or EnvironmentVariables() module_env_vars['DJANGO_SETTINGS_MODULE'] = env_vars[module_settings] old_env_vars = module._app_info_external.env_variables new_env_vars = EnvironmentVariables.Merge(module_env_vars, old_env_vars) module._app_info_external.env_variables = new_env_vars self._dispatcher._configuration = configuration self._dispatcher._port = options.port self._dispatcher._host = options.host # Because the dispatcher is a singleton, we need to set the threadsafe override here # depending on what was passed to the runserver command. This entire file really needs rebuilding # we have way too many hacks in here! self._dispatcher._module_to_threadsafe_override[ configuration.modules[0].module_name ] = options.threadsafe_override self._dispatcher.request_data = request_data request_data._dispatcher = self._dispatcher sandbox._API_SERVER._host = options.api_host sandbox._API_SERVER.bind_addr = (options.api_host, options.api_port) from google.appengine.api import apiproxy_stub_map task_queue = apiproxy_stub_map.apiproxy.GetStub('taskqueue') # Make sure task running is enabled (it's disabled in the sandbox by default) if not task_queue._auto_task_running: task_queue._auto_task_running = True task_queue.StartBackgroundExecution() return sandbox._API_SERVER
def _create_api_server(self, request_data, storage_path, options, configuration): self._dispatcher = sandbox._create_dispatcher( configuration, options) self._dispatcher._port = options.port self._dispatcher._host = options.host self._dispatcher.request_data = request_data request_data._dispatcher = self._dispatcher sandbox._API_SERVER._host = options.api_host sandbox._API_SERVER.bind_addr = (options.api_host, options.api_port) from google.appengine.api import apiproxy_stub_map task_queue = apiproxy_stub_map.apiproxy.GetStub('taskqueue') # Make sure task running is enabled (it's disabled in the sandbox by default) if not task_queue._auto_task_running: task_queue._auto_task_running = True task_queue.StartBackgroundExecution() return sandbox._API_SERVER
def _set_dispatcher(self, dispatcher): """ Ignore explicit setting of _dispatcher, use our own """ if dispatcher is None: # Allow wiping the patched dispatcher self._patched_dispatcher = None return if self._patched_dispatcher: # We already created the dispatcher, ignore further sets logging.warning("Attempted to set _dispatcher twice") return # When the dispatcher is created this property is set so we use it # to construct *our* dispatcher configuration = dispatcher._configuration # We store options in .start() so it's available here options = self.options # sandbox._create_dispatcher returns a singleton dispatcher instance made in sandbox self._patched_dispatcher = sandbox._create_dispatcher( configuration, options ) # the dispatcher may have passed environment variables, it should be propagated env_vars = self._dispatcher._configuration.modules[0]._app_info_external.env_variables or EnvironmentVariables() for module in configuration.modules: module_name = module._module_name if module_name == 'default' or module_name is None: module_settings = 'DJANGO_SETTINGS_MODULE' else: module_settings = '%s_DJANGO_SETTINGS_MODULE' % module_name if module_settings in env_vars: module_env_vars = module.env_variables or EnvironmentVariables() module_env_vars['DJANGO_SETTINGS_MODULE'] = env_vars[module_settings] old_env_vars = module._app_info_external.env_variables new_env_vars = EnvironmentVariables.Merge(module_env_vars, old_env_vars) module._app_info_external.env_variables = new_env_vars self._dispatcher._configuration = configuration self._dispatcher._port = options.port self._dispatcher._host = options.host # Because the dispatcher is a singleton, we need to set the threadsafe override here # depending on what was passed to the runserver command. This entire file really needs rebuilding # we have way too many hacks in here! self._dispatcher._module_to_threadsafe_override[ configuration.modules[0].module_name ] = options.threadsafe_override # self._dispatcher.request_data = request_data # request_data._dispatcher = self._dispatcher sandbox._API_SERVER._host = options.api_host sandbox._API_SERVER.bind_addr = (options.api_host, options.api_port) from google.appengine.api import apiproxy_stub_map task_queue = apiproxy_stub_map.apiproxy.GetStub('taskqueue') # Make sure task running is enabled (it's disabled in the sandbox by default) if not task_queue._auto_task_running: task_queue._auto_task_running = True task_queue.StartBackgroundExecution()
def _create_api_server(self, request_data, storage_path, options, configuration): self._dispatcher = sandbox._create_dispatcher(configuration, options) request_data._dispatcher = self._dispatcher return sandbox._API_SERVER