def load(self, config, container_builder): extensions = container_builder.parameters.get('ioc.extensions') locator_map = {} for extension in extensions: locator_map[extension] = Definition( 'ioc.locator.ChoiceLocator', arguments=[[ Definition('ioc.locator.FileSystemLocator', arguments=[ "%s/resources/%s" % (container_builder.parameters.get( 'project.root_folder'), extension) ]), Definition('ioc.locator.PackageLocator', arguments=[extension], kwargs={'package_path': 'resources'}) ]]) container_builder.add( 'ioc.locator', Definition('ioc.locator.PrefixLocator', arguments=[locator_map], kwargs={'delimiter': ':'}))
def get_firewall_context(self, name, settings, container_builder, auth_providers): handlers = [] # create the FlaskContextHandler, this service load token from flask session handling context_handler = Definition('element.plugins.security.handler.FlaskContextHandler', [ Reference('element.plugins.security.context'), Reference('element.plugins.security.provider.in_memory'), # this need to be configurable settings.get('context', name) ], {'logger': Reference('element.logger')}) context_handler.add_tag('event.listener', { 'name': 'element.response', 'method': 'handleResponse', 'priority': 32 }) handlers.append(context_handler) for position in self.listenerPositions: for factory in self.factories[position]: if not settings.get(factory.key): continue auth_provider_id, handler_id, entry_point_id = factory.create(container_builder, name, settings.get(factory.key)) handlers.append(Reference(handler_id)) auth_providers.append(auth_provider_id) container_builder.add('element.plugins.security.handlers.flask_context.%s' % name, context_handler) if settings.get("anonymous", False): id_anonymous = 'element.plugins.security.listener.anonymous.%s' % name container_builder.add(id_anonymous, Definition('element.plugins.security.handler.AnonymousAuthenticationHandler', [name, Reference('element.plugins.security.context')], {'logger': Reference('element.logger')} )) handlers.append(Reference(id_anonymous)) handlers.append(Reference('element.plugins.security.handlers.access_map')) return (handlers, None)
def load(self, file, container_builder): try: data = yaml.load(open(file).read(), OrderedDictYAMLLoader) except yaml.scanner.ScannerError as e: raise ioc.exceptions.LoadingError("file %s, \nerror: %s" % (file, e)) for extension, config in data.items(): if extension in ['parameters', 'services']: continue if config == None: config = {} container_builder.add_extension(extension, self.fix_config(config.copy())) if 'parameters' in data: for key, value in data['parameters'].items(): container_builder.parameters.set(key, value) if 'services' in data: for id, meta in data['services'].items(): if 'arguments' not in meta: meta['arguments'] = [] if 'class' not in meta: meta['class'] = None if 'kwargs' not in meta: meta['kwargs'] = {} if 'calls' not in meta: meta['calls'] = [] if 'tags' not in meta: meta['tags'] = {} if 'abstract' not in meta: meta['abstract'] = False definition = Definition( clazz=meta['class'], arguments=self.set_references(meta['arguments']), kwargs=self.set_references(meta['kwargs']), abstract=meta['abstract']) for call in meta['calls']: if len(call) == 0: continue if len(call) == 2: call.append({}) if len(call) == 1: call.append([]) call.append({}) definition.method_calls.append( (call[0], self.set_references(call[1]), self.set_references(call[2]))) for tag, options in meta['tags'].items(): for option in options: definition.add_tag(tag, option) container_builder.add(id, definition)
def load(self, file, container_builder): try: data = yaml.load(open(file).read(), OrderedDictYAMLLoader) except yaml.scanner.ScannerError as e: raise ioc.exceptions.LoadingError("file %s, \nerror: %s" % (file, e)) for extension, config in data.items(): if extension in ['parameters', 'services']: continue if config == None: config = {} container_builder.add_extension(extension, self.fix_config(config.copy())) if 'parameters' in data: for key, value in data['parameters'].items(): container_builder.parameters.set(key, value) if 'services' in data: for id, meta in data['services'].items(): if 'arguments' not in meta: meta['arguments'] = [] if 'class' not in meta: meta['class'] = None if 'kwargs' not in meta: meta['kwargs'] = {} if 'calls' not in meta: meta['calls'] = [] if 'tags' not in meta: meta['tags'] = {} if 'abstract' not in meta: meta['abstract'] = False definition = Definition( clazz=meta['class'], arguments=self.set_references(meta['arguments']), kwargs=self.set_references(meta['kwargs']), abstract=meta['abstract'] ) for call in meta['calls']: if len(call) == 0: continue if len(call) == 2: call.append({}) if len(call) == 1: call.append([]) call.append({}) definition.method_calls.append( (call[0], self.set_references(call[1]), self.set_references(call[2])) ) for tag, options in meta['tags'].items(): for option in options: definition.add_tag(tag, option) container_builder.add(id, definition)